Tim Driven Development | Test until the fear goes away
Guillermo Ishi wrote:Where is the unreachable code? I'm getting results that contradict what I've read I'm supposed to get.
Tim Cooke wrote:What results did you get? What results were you expecting, and why?
Guillermo Ishi wrote:I've been led to believe 1,2,and 3 should be reachable.
Guillermo Ishi wrote:I still don't have confidence in what is going on in the snippet though.
Guillermo Ishi wrote:So the rules seem to be if you have a return in a finally block, anything after the finally block is always unreachable.
Guillermo Ishi wrote:I'm assuming here if some condition isn't met so the try that goes with the finally is never executed, then that is false..
Guillermo Ishi wrote:If you do not have a finally block, then 4 is reachable (but not necessarily reached if catch has a return).
Guillermo Ishi wrote:If you have a catch and a finally both with returns and an exception was thrown both returns get evaluated but the returned value is the one in finally.
Guillermo Ishi wrote:It seems to depend on whether the compiler knows it's unreachable without it having to think very hard...
Catch Ernie! Catch the egg! And catch this tiny ad too:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|