Marcello Barnaba
2/20/2007 8:27:00 PM
Hi,
On Tuesday 20 February 2007 21:14, ara.t.howard@noaa.gov wrote:
> On Wed, 21 Feb 2007, Marcello Barnaba wrote:
> > Hi,
> >
> > On Tuesday 20 February 2007 21:02, Patrick Hurley wrote:
> >> I am not recommending this, but you can force a binding into an eval.
> >> However, due to how the Ruby parser identifies local variables, they
> >> need to be referenced in "code" before you can use them normally.
> >
> > my irb disagrees:
> >
> > vjt@neutrino:~$ irb
> > /home/vjt| irb(main):001:0> eval 'x = 42', binding
> > 42
> > /home/vjt| irb(main):002:0> x
> > 42
> > /home/vjt| irb(main):003:0> RUBY_VERSION
> > "1.8.5"
> > /home/vjt| irb(main):004:0>
>
> try writing that in a script.
vjt@neutrino:~$ ruby -e "eval('x=42',binding); x"
-e:1: undefined local variable or method `x' for main:Object (NameError)
> in irb you are __already__ in eval. google the archives for more info.
gotcha! :) thanks
--
pub 1024D/8D2787EF 723C 7CA3 3C19 2ACE 6E20 9CC1 9956 EB3C 8D27 87EF