just curious why I cann’t remove declared local variable from ‘local_variables’ array.
Example:
x=1
myarr = local_variables.clone
p local_variables
=> [:x, :_]
p myarr
=> [:x, :_]
p local_variables.class
=> Array
p myarr.class
=> Array
myarr.delete :x
p myarr
=> [:_]
local_variables.delete :x
p local_variables
=> [:x, :_]
WTF ?
I did suspected calling local_variables.delete with parameter 😡 reinserts it back as it is declared anew. But if called with other previously undeclared symbol does not change it:
p local_variables
=> [:x, :_]
local_variables.delete :whatever
p local_variables
=> [:x, :_]
Can somebody explain ?
Thx.
Consider the following method:
Does that behaviour surprise you?
Every time you call
local_variables(orfoo) a new array is created. If you modify that new array that has no effect on what will happen if you calllocal_variablesagain.