From: Heesob Park Date: 2008-05-23T18:13:33+09:00 Subject: Re: Why can't I define vars in caller's binding using eval? 2008/5/23 Andrew Mitchell : > 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 >>> But it works only in irb. Regards, Park Heesob