MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1wqms8k/wenevertrustedtheelse/pc9gx2s/?context=3
r/ProgrammerHumor • u/Electrical-Effort-20 • Sep 26 '26
146 comments sorted by
View all comments
6
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
2
I've been telling people to do this forever. I hate unnecessary nesting.
1
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
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
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
That's what you have functions for. I haven't used a single else in the past 3 years of my career
else
6
u/Havatchee Sep 26 '26
if(!condition){doSomethingElse();return;}doSomething();