Dynamically set local variables in Ruby [duplicate]
-
12-11-2019 - |
Question
I'm interested in dynamically setting local variables in Ruby. Not creating methods, constants, or instance variables.
So something like:
args[:a] = 1
args.each_pair do |k,v|
Object.make_instance_var k,v
end
puts a
> 1
I want locally variables specifically because the method in question lives in a model and I dont want to pollute the global or object space.
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow