I follow the “Why Poignant Guide to Ruby” to learn Ruby, and I have problems when he first introduces the “require” (?) Method in his tutorial.
Essentially, I am making a file called "wordlist.rb" that contains:
code_words = { 'starmonkeys' => 'Phil and Pete, those prickly chancellors of the New Reich', 'catapult' => 'chucky go-go', 'firebomb' => 'Heat-Assisted Living', 'Nigeria' => "Ny and Jerry Dry Cleaning (with Donuts)", 'Put the kabosh on' => 'Put the cable box on' }
Then I have another ruby script called "files.rb":
require 'wordlist'
When I try to run the Ruby script i get:
files.rb: 9: undefined local variable or method `code_words' for main: Object (NameError)
Any idea how to make the “require” work correctly to refer to a list of words?
source share