Nobuyoshi Nakada
2/14/2009 9:49:00 AM
Hi,
At Sat, 14 Feb 2009 16:52:12 +0900,
7stud -- wrote in [ruby-talk:328185]:
> > require separates the scope, so local variables defined outside
> > are not accessible.
> >
>
> 1) require? Where, what, when?
Sorry, it was load.
> > $ ruby -e 'x=10; eval(File.read($0 = ARGV.shift), binding)' r1test.rb
> > hello
> > 10
>
> 2) Isn't specifying 'binding' redundant unless you acquire a binding
> from a different scope?
Just for explanation.
> 3) Why the $0 = ARGV.shift ? This appears to work the same way:
>
> $ ruby -e 'x=10; eval(File.read(ARGV[0]) )' r1test.rb
For the idiom, if $0 == __FILE__.
--
Nobu Nakada