Related questions
Dynamically set local variables in Ruby
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 …
Undefine variable in Ruby
Let's say I'm using irb, and type a = 5. How do I remove the definition of a so that typing a returns a NameError?
Some context: later I want to do this:
context = Proc.new{}.binding
context.eval 'a = 5'
context.…