Access variable in require'd ruby code -
this question has answer here:
- how share variables across .rb files? 3 answers
what's scope of variable in piece of code has been require'd?
e.g. have piece of code in file called users.rb:
users = ... and line not in class or in method. require file. e.g. in app.rb
require './users.rb' what's scope of variable (users) , how access it?
variables start lower case letter local variables. local variables called local variables because local scope defined in , cannot accessed different scope.
what's scope of variable in piece of code has been
require'd?
in particular case, scope script body of users.rb.
how access it?
you can't. that's whole purpose of local variables.
Comments
Post a Comment