On Jun 22, 2007, at 11:33 AM, hellfeuer / gmail.com wrote:

> if i do this in the top level:
>> foo = lambda {p a}
>> eval "a=1"
>> foo.call
>
> It doesn't work, giving me a NameError: undefined variable or  
> method in
> main:Object

It will work if the local variable has been defined before the Proc  
object is created. That is, the local variable must exist before the  
closure is made.

<code>
a = nil
foo = lambda { a }
eval("a = 42")
foo.call # => 42
</code>

Regards, Morton