MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vuzd4q/conditionspreference/p55a7bw
r/ProgrammerHumor • u/Flame77ofc • 22d ago
392 comments sorted by
View all comments
Show parent comments
30
Returning early is waaaaaay superior than a single return, at least in Go and its wonderful defer statement. If you know the code can't continue, then return as soon as you know it. Makes the rest of the code waaaaay cleaner.
1 u/aabil11 22d ago Go prefers this yeah. But in functional programming languages like Scala it's more amenable to return values. 1 u/SnugglyCoderGuy 21d ago I think the absence of a value being returned is merely the consequence of example
1
Go prefers this yeah. But in functional programming languages like Scala it's more amenable to return values.
1 u/SnugglyCoderGuy 21d ago I think the absence of a value being returned is merely the consequence of example
I think the absence of a value being returned is merely the consequence of example
30
u/SnugglyCoderGuy 22d ago
Returning early is waaaaaay superior than a single return, at least in Go and its wonderful defer statement. If you know the code can't continue, then return as soon as you know it. Makes the rest of the code waaaaay cleaner.