Say I have:
begin
2.times do
a = 1
1/0
end
rescue
puts $!
debugger
end
In this example, I want to get the value of a. If a is initialised in the begin block then I can access it when I rescue. However, in this example, a is block-local. Is there a way to get the binding at the moment of the exception, when I rescue?
Can't you just put another begin,rescue block inside of the do block?
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