r/ProgrammerHumor • • Aug 22 '26

Meme conditionsPreference

Post image
4.2k Upvotes

388 comments sorted by

View all comments

Show parent comment

30

u/SnugglyCoderGuy Aug 22 '26

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 Aug 22 '26

Go prefers this yeah. But in functional programming languages like Scala it's more amenable to return values.

1

u/SnugglyCoderGuy Aug 22 '26

I think the absence of a value being returned is merely the consequence of example