From: Warren Brown Date: 2003-06-27T02:08:13+09:00 Subject: Re: Another Run Time Evaluation Q: > My example work not because the variable was > created before the eval, but because ruby has > seen *at compile time* that `a' is a variable. > > If you write > > ruby -ve 'str = "a=2"; eval(str,binding); puts a' > > at compile time, `puts a' is interpreted as a > method call, i.e. `puts a()' To further illustrate this point: irb(main):001:0> VERSION => "1.6.8" irb(main):002:0> str = "a = 2"; eval(str); puts a NameError: undefined local variable or method `a' for # from (irb):2 irb(main):003:0> a => 2 irb(main):004:0> - Warren Brown