# test_binding.rb
expression = "-> do
result = 1 + @x
puts result
end"
test_lambda = -> { @x = 1 }
exp = eval(expression, test_lambda.binding)
exp.call
# I am expecting to see the result 2 being puts-ed to the screen.
# instead I'm seeing the following:
# (eval):2:in `+': nil can't be coerced into Integer (TypeError)
# from (eval):2:in `block in <main>'
# from test_binding_and_eval.rb:13:in `<main>'
# what am i doing wrong?
Any pointers would be appreciated?