The exact details of why this I'm not familiar w/ but it is a scope
issue.  The require won't make the local variable into global for you.

The 'myhash' isn't global just because it is declared outside of other
things.. prefix that myhash w/ a $ and make it a global.

$myhash =  { "a" => "ay", "b" => "bee", "c" => "sea" }

-----------

puts $myhash['a']


-dayne

On 12/18/05, Grehom <grehom / ntlworld.com> wrote:
> 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.
>
>
>