Timothy Goddard
6/25/2006 6:06:00 AM
Generally only constants should be exposed after a require. Use a
capital letter at the start of the variable name and it should work.
Alternatively, have the required script store values in global
variables (beginning with a $ sign).
dave wrote:
> i'm still a newbie doing every example in whys-poignant-guide-to-ruby,
> i don't understand why code_words hash initialized in my wordlist.rb is
> unavailable to my ruby program that requires it... the contains of
> wordlist.rb : code_words={hash of code word}...and puts that prints it
> out so i know that not only it is syntactly correct and initializes
> code_words correct and it runs to completion when it 'requires' it
> BUT... the next debug stmt (that i put in) of the ruby program doing
> the requiring produces this error: codewordtranslator.rb:3: undefined
> local variable or method `code_words' for main:Object (NameError)
> >Exit code: 1
> and even in IRB same thing happens...why? .... what i'm doing wrong
> here...trying to understand...tia dave