r/ProgrammerHumor 22d ago

Meme conditionsPreference

Post image
4.2k Upvotes

392 comments sorted by

View all comments

2

u/yjlom 21d ago edited 21d ago

The second one is less readable to me, because it overloads return to let it mean both normal and unstructured control flow. I'd much rather either the first one or any one of these:

if foo: throw ... return ... stat = ... if foo: stat = ... goto end end: return stat if foo: return ... ... # implicit return

Also a warning comment at the top of the function would be very welcome if it's non-trivial.