Access variable in require'd ruby code -


this question has answer here:

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

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -