RosettaCodeData/Task/Runtime-evaluation-In-an-environment/Ruby/runtime-evaluation-in-an-environment.rb
Ingy döt Net b83f433714 tasks a-s
2013-04-10 23:57:08 -07:00

9 lines
184 B
Ruby

def bind_x_to_value(x)
binding
end
def eval_with_x(code, a, b)
eval(code, bind_x_to_value(b)) - eval(code, bind_x_to_value(a))
end
puts eval_with_x('2 ** x', 3, 5) # Prints "24"