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

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -