From: Tony Arcieri Date: 2010-10-07T06:12:23+09:00 Subject: Re: setting local variables in a binding --0016e659f4e8a9e69c0491f93b0c Content-Type: text/plain; charset=ISO-8859-1 Note that "binding" is the default argument of eval if you don't specify one, so capturing binding as a variable and passing it explicitly is redundant. On Wed, Oct 6, 2010 at 1:53 PM, Martin DeMello wrote: > On Thu, Oct 7, 2010 at 12:38 AM, John Sikora > wrote: > > Hmmm, it seems to work when x is already defined (in 1.9.2): > > > > irb(main):001:0> x=4 > > => 4 > > irb(main):002:0> b=binding > > => # > > irb(main):003:0> eval("x=5", b) > > => 5 > > irb(main):004:0> x > > => 5 > > irb(main):005:0> > > > > If I do not set x to a value beforehand, I get the same error. Do not > > know why though. > > Oddly enough, if x is defined beforehand you don't even need the binding: > > ruby-1.9.2-p0 > x = 5 > => 5 > ruby-1.9.2-p0 > eval "x = 42" > => 42 > ruby-1.9.2-p0 > x > => 42 > > martin > > -- Tony Arcieri Medioh! A Kudelski Brand --0016e659f4e8a9e69c0491f93b0c--