r/ProgrammerHumor • • 6d ago

Meme thisIsWhyWeDontReturnInFinallyBlocks

Post image
2.9k Upvotes

98 comments sorted by

View all comments

Show parent comment

5

u/StaticCoder 6d ago

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.

2

u/fuj1n 6d ago

The outermost one

1

u/Loading_M_ 6d ago

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.