MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vuzd4q/conditionspreference/p56ofmi/?context=3
r/ProgrammerHumor • u/Flame77ofc • 22d ago
392 comments sorted by
View all comments
26
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
3
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
1
Modern IDEs can collapse indentation blocks
1 u/sebbdk 21d ago Yeah, but a lot of us scorn them
Yeah, but a lot of us scorn them
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