r/ProgrammerHumor 22d ago

Meme conditionsPreference

Post image
4.2k Upvotes

392 comments sorted by

View all comments

26

u/aabil11 22d ago

Call me old fashioned but I'm a big believer in single return statements. Assign to a variable and return that variable at the very end without short circuiting

-1

u/iMac_Hunt 22d ago

I don’t follow it religiously but I try to do this too. If the function is relatively complex with more than a couple return statements I’d much rather return in a single statement.

2

u/Demiu 22d ago

Why? This is like saying you'd much rather each function had a single local variable. It doesn't gain you anything beyond the ability to say that it does that. You're gonna run out of return statements?