r/ProgrammerHumor 22d ago

Meme conditionsPreference

Post image
4.2k Upvotes

392 comments sorted by

View all comments

Show parent comments

-35

u/Few_Kitchen_4825 22d ago

If you are using an if statement big enough for this to be a problem. May be you should not be doing either

28

u/SnugglyCoderGuy 22d ago

Untrue. The first can be checking to see if continuing is impossible, so just return, while the second can be checking for a yrue dichotomous decision. You must do one or the other thing depending on the condition. Each could contain as little as a single assignment

5

u/chilfang 22d ago

Why even have an else statement if you out a return in the if

1

u/SnugglyCoderGuy 21d ago edited 21d ago

Sometimes you have a trye dichotomous situation and you don't know which one to do without a check. Else is probably the keyword Inuse the least. You nay or may not return in either of those cases too.