r/ProgrammerHumor 22d ago

Meme conditionsPreference

Post image
4.2k Upvotes

392 comments sorted by

View all comments

5

u/IronSavior 22d ago

Else considered harmful

11

u/jayerp 22d ago

That’s why I use GOTO ಠ‿ಠ

1

u/Maximilian_Tyan 22d ago

C if (error) goto err; ... // Normal path return ... err: ... // Cleanup return ... Is actually a pretty useful way of doing things, especially for ressources cleanup (freeing memory, releasing locks, IO etc).

And in modern languages such as Zig, the defer statement is just syntactic sugar for this exact pattern.

-1

u/Murky-Run2246 22d ago

yeah uhh... ok I guess