Yield self

recently someone posted a very cool method which, given an object, would yield
a block of code with the value of self as that object.

anyone remember this? i can’t seem to find it…

-a

···

Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ara.t.howard@fsl.noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
====================================

ahoward wrote:

recently someone posted a very cool method which, given an object, would yield
a block of code with the value of self as that object.

anyone remember this? i can’t seem to find it…

Do you mean instance_eval?

no - i least i think i don’t… perhaps i was dreaming? hope not, it was kind
of neat!

-a

···

On Sat, 26 Apr 2003, Joel VanderWerf wrote:

ahoward wrote:

recently someone posted a very cool method which, given an object, would yield
a block of code with the value of self as that object.

anyone remember this? i can’t seem to find it…

Do you mean instance_eval?

Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ara.t.howard@fsl.noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
====================================

ahoward wrote:

recently someone posted a very cool method which, given an object, would yield
a block of code with the value of self as that object.

anyone remember this? i can’t seem to find it…

Do you mean instance_eval?

no - i least i think i don’t… perhaps i was dreaming? hope not, it was kind
of neat!

Do you mean this?

def with(object, &block)
object.instance_eval(&block)
end
=> nil
with “1” do
?> puts “My length is #{length}”
end
My length is 1
=> nil

As usual, all rights reserved, etc; BTW I prefer cheques payable to bearer :wink:
At least 80% of the profits will be reinvested in food for my brain (*) so that I
can go on posting here.

The way “new syntax” can be added so easily to Ruby never ceases to
amaze me.

(*) includes foodstuffs and “food for thought”

···

On Sat, Apr 26, 2003 at 10:06:10AM +0900, ahoward wrote:

On Sat, 26 Apr 2003, Joel VanderWerf wrote:


_ _

__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_ _ \ / ` | ’ \
) | (| | |
__ \ | | | | | (| | | | |
.__/ _,
|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

I’m telling you that the kernel is stable not because it’s a kernel,
but because I refuse to listen to arguments like this.
– Linus Torvalds

Do you mean this?

yes. thanks!

def with(object, &block)
object.instance_eval(&block)
end
=> nil
with “1” do
?> puts “My length is #{length}”
end
My length is 1
=> nil

As usual, all rights reserved, etc; BTW I prefer cheques payable to bearer
:wink: At least 80% of the profits will be reinvested in food for my brain (*)
so that I can go on posting here.

do you take paypal? :wink:

The way “new syntax” can be added so easily to Ruby never ceases to amaze
me.

amongst other things - agreed.

-a

···

On Sat, 26 Apr 2003, Mauricio [iso-8859-1] Fernández wrote:

Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ara.t.howard@fsl.noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
====================================