Christian Surlykke
11/12/2006 2:07:00 PM
Hi,
Is it possible to create a new local variable in a binding after it's creation?
Specifically, what I'd like to do:
l = lambda { puts a } # 'a' not defined at this point.
eval('a = 7', l.binding) # Hope to create a in l's binding
l.call # Hope to get '7'
- but that produces:
NameError: undefined local variable or method `a' for main:Object
from (irb):1
from (irb):3:in `call'
from (irb):3
from :0
Apparently, 'a' gets created in the scope from where 'eval' was called and not in 'l'''s binding.
Any suggestions would be most welcome.
best regards
Christian Surlykke