From: Andrew Mitchell Date: 2008-05-23T17:39:51+09:00 Subject: Re: Why can't I define vars in caller's binding using eval? Christopher J. Bottaro wrote: > In other words, why can't I do this? > > def f(b) > eval("x = 10", b) > end > > f(binding) > puts "x = #{x}" > > Is there any way to make that code work (besides obviously setting x > to something before calling f). > > Thanks. Worked for me. Dios:~ andrewmitchell$ irb >> def f(b) >> eval("x=10", b) >> end => nil >> f(binding) => 10 >> puts "x = #{x}" x = 10 => nil >> -- Posted via http://www.ruby-forum.com/.