"ts" <decoux / moulon.inra.fr> wrote in message
>  irb do someting like this
>
> svg% ruby -e 'eval("a=2"); eval("puts a")'
> 2

Oh, I see.

>  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()'
>
>  Now with
>
>    ruby -ve 'a = nil; str = "a=2"; eval(str,binding); puts a'
>
>  when ruby compile the script, it see that `a' is a local variable and
>  `puts a' is interpreted as an access to the local variable `a'

Got it ! Thanks for taking time to explain this in detail.

> Guy Decoux
>