In article <3E2C5674.8020002 / path.berkeley.edu>,
Joel VanderWerf  <vjoel / PATH.Berkeley.EDU> wrote:
>Daniel Carrera wrote:
>
>> Since 'foo' was defined before 'function' and both 'function' and 'foo' 
>> are in the same scope (I think) shouldn't 'function' see 'foo'?
>
>You can do this in 1.7:
>
>module M
>   foo = "bar"
>   define_method :function do
>     puts foo
>   end
>end
>include M
>
>function      # prints: bar

This falls into the catagory of 
one-of-those-1.8-features-I-didn't-know-about.

So define_method can define a method that 'knows' about all of the 
variables in the scope in which it is defined?  Useful, but one needs to 
be careful.

Phil

-- 
"Or perhaps the truth is less interesting than the facts?" 
Amy Weiss (accusing theregister.co.uk of engaging in 'tabloid journalism')
Senior VP, Communications
Recording Industry Association of America