G
Grehom
I have one line of code in a file called 'stuff.rb':
myhash = { "a" => "ay", "b" => "bee", "c" => "sea" }
and I wish to include it in another program called 'mainprog.rb' thus:
require 'stuff'
puts " a = " + myhash["a"]
when I run it I get an error message:
mainprog.rb:4: undefined local variable or method `myhash' for
main:Object (NameError)
I guess I must be doing something dumb - I am basing this code on
examples in 'Why's (poignant) guide to Ruby'. I am using the very
latest Windows version under XP Pro:
C:\rubysrcs>ruby -v
ruby 1.8.2 (2004-12-25) [i386-mswin32]
which I installed using the exe file: ruby182-15.exe
everything else I've tried seems to be working fine. Thanks.
myhash = { "a" => "ay", "b" => "bee", "c" => "sea" }
and I wish to include it in another program called 'mainprog.rb' thus:
require 'stuff'
puts " a = " + myhash["a"]
when I run it I get an error message:
mainprog.rb:4: undefined local variable or method `myhash' for
main:Object (NameError)
I guess I must be doing something dumb - I am basing this code on
examples in 'Why's (poignant) guide to Ruby'. I am using the very
latest Windows version under XP Pro:
C:\rubysrcs>ruby -v
ruby 1.8.2 (2004-12-25) [i386-mswin32]
which I installed using the exe file: ruby182-15.exe
everything else I've tried seems to be working fine. Thanks.