I want to define the block as a string, then create the lambda. The following example does not work. Is something like this possible?
code_string = "|x|x*2"
l = lambda {eval(code_string)}
l.call(3) => 6
This works
eval "lambda { " + code_string + " }"
I just don't know why this one does and the other does not.
eval "lambda {#{code_string}}"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With