Early return might not be language specific, but they are paradigm specific.
return
While returning early can make sense in a statement-oriented language, they aren't nearly as popular in expression-oriented languages.
In at least one (Scala), an explicit return of any kind, but especially an early return, is explicitly an anti-pattern.
Of course, most of these languages have pattern matching, which is a great alternate to both switch and complex if...else blocks.
switch
if...else
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Early
return
might not be language specific, but they are paradigm specific.While returning early can make sense in a statement-oriented language, they aren't nearly as popular in expression-oriented languages.
In at least one (Scala), an explicit
return
of any kind, but especially an earlyreturn
, is explicitly an anti-pattern.Of course, most of these languages have pattern matching, which is a great alternate to both
switch
and complexif...else
blocks.