ruby require does not load variable - undefined local variable -
have external file, wordlist.rb, contains
code_words = { 'a' => 'is a', 'b' => 'is b' } this file stored in same directory contains code require 'wordlist'
code_word.each | mykey, mysentence | puts mykey + "=> " mysentence end when run code, following message
<main>': undefined local variable or method code_words' main:object (nameerror) thanks help
you should have global variable(i.e. starting $) able access file require.
Comments
Post a Comment