From: Morton Goldberg Date: 2007-06-23T05:19:27+09:00 Subject: Re: eval, bindings and scope 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. a = nil foo = lambda { a } eval("a = 42") foo.call # => 42 Regards, Morton