D
Dave Baldwin
This behaviour has rather surprised me:
file a.rb
a = 10
file b.rb
require "a.rb"
puts a
dave 123% ruby b.rb
b.rb:2: undefined local variable or method `a' for main:Object
(NameError)
dave 124% ruby -v
ruby 1.8.1 (2003-10-31) [powerpc-darwin]
Using $a fixes this but I don't want to do this or I could join the
two files at run time and eval them.
I didn't expect the scope of a to be private to a.rb and can find no
mention in pickaxe about this.
Dave.
file a.rb
a = 10
file b.rb
require "a.rb"
puts a
dave 123% ruby b.rb
b.rb:2: undefined local variable or method `a' for main:Object
(NameError)
dave 124% ruby -v
ruby 1.8.1 (2003-10-31) [powerpc-darwin]
Using $a fixes this but I don't want to do this or I could join the
two files at run time and eval them.
I didn't expect the scope of a to be private to a.rb and can find no
mention in pickaxe about this.
Dave.