When i execute the makeSwamp.rb file i can enter a “new idea” but than i
get:
/makeSwamp.rb:8: undefined local variable or method `code_words’ for
main:Object (NameError)
(line 8 is: code_words.each do |real, code| )
Why ??? I’ve run kdiff and its exactly as in the tutorial… Maybe its
just to late for me…
When you require (or load) a file, the local variables are not brought
in. Try changing code_words to a global variable by making it
“$code_words” (in both files). Or if you think it’s more appropriate,
change it to a constant by making it “CodeWords” in both files.
Eric
Are you interested in on-site Ruby training that uses well-designed,
real-world, hands-on exercises? http://LearnRuby.com
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.