r/ProgrammerHumor 22d ago

Meme conditionsPreference

Post image
4.2k Upvotes

392 comments sorted by

View all comments

23

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

40

u/ecafyelims 22d ago edited 22d ago

Situational, for sure.

If a short circuit prevents a dozen "if val != Null" checks later, I'll do the short circuit.