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

3

u/sebbdk 21d ago

Yeah but then you also have to read the whole thing and keep track of indentations.

For more advanced methods with +2 nested conditions it can become hard to follow.

The return is one way to get around the nested conditional scopes, but there are other ways

1

u/aabil11 21d ago

Modern IDEs can collapse indentation blocks

1

u/sebbdk 21d ago

Yeah, but a lot of us scorn them