If I require 'helper_file' in a program and there are constants and variables declared in that required file is there a way to access those variables and constants?
require 'helper_file'
...some nice code
x = ConstantFromRequireFile
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You use require to load a library into your Ruby program. It will return true if successful.
So you have a file example.rb:
and a file library.rb:
As you can see you access the constant and the method as you would access a constant and a method from the same file.
You can read more about require here: What is the difference between include and require in Ruby? and here: Kernal Module in Ruby