From: Joel VanderWerf Date: 2009-08-11T05:43:12+09:00 Subject: Re: instance_variables vs. local_variables David Whetstone wrote: > So the implication here is that there is no way to define a local > variable at run time. Investigating this question is, in fact, what > lead me the above discovery. This is disappointing if true. > > I can use method_missing to simulate late binding of local variables, > but it is inefficient to have method_missing called every time such a > variable is referenced. (No, I have not profiled to see if this is > really a performance concern, it just smells bad to me.) > > Am I correct? Is what I would like to do currently impossible? If you are eval-ing code, then you can eval against a binding, and define locals at run time in that binding: def get_empty_binding binding end b = get_empty_binding eval("a=1", b) p eval("a", b) # ==> 1 Not sure this is what you're looking for. -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407