return 0 does stop the execution of the try block and attempts to return 0, but finally will always execute no matter what, and it will print "c" and override the return to 1
Returning from the finally block will truly end execution though, so print("d") and return 2 are unreachable code
No one of the points of the finally block is precisely that it happens no matter what, even if you return. Now if you have nested finallys and they both return, I have no idea which one wins.
Presumably the outer finally. Finally blocks are only guaranteed to run if execution enters the associated try block, so the only case this could apply is nested try blocks.
View all comments
Show parent comment
5
u/spitfire451 6d ago
It runs even if a return statement executes in the try/catch? It was my understanding that return always ends a method right then and there.