Reputation: 3938
I am learning Ruby and reading a piece of code. I don't understand this line:
require @a_variable
In my limited knowledge on Ruby, "require" is used to import modules, classes, or whatever stuff in other files. What is the usage there? I browsed a lot but can't find an explanation. Thanks.
Upvotes: 1
Views: 39
Reputation: 30056
Here's the thing. You have to pass a string to require
. If that's a string literal or an expression which evaluates to a string doesn't matter.
require 'set'
or
set = 'set'
require set
is equivalent
Upvotes: 3