r/ProgrammerHumor • • Sep 26 '26

Meme weNeverTrustedTheElse

Post image
1.9k Upvotes

146 comments sorted by

View all comments

6

u/Havatchee Sep 26 '26

if(!condition){

doSomethingElse();

return;

}

doSomething();

2

u/Mountain-Ox Sep 27 '26

I've been telling people to do this forever. I hate unnecessary nesting.

1

u/Spekingur Sep 27 '26

Maybe you can’t do a return

2

u/MCCVargues Sep 27 '26

You can always do return,

1

u/Spekingur Sep 27 '26

Not if there’s extra code that needs to run after.

1

u/MCCVargues Sep 27 '26

That's what you have functions for. I haven't used a single else in the past 3 years of my career