Ruby IRB - Requires and Scope
- by tyndall
Trying to understand this problem I'm running into.
I create file welcome.rb.
The contents of this file:
welcome_message = "hi there"
I then launch an irb session.
And type require 'welcome'. That works fine.
Then I type:
puts welcome_message
I get the error message undefined local variable or method `welcome_message' for main:Object
What is the best way to bring in predefined variables and have initialization work done when you require something into your irb session. Global variables didn't seem like the right path.