4

Not loving the implicit return statement within Scala. I like to avoid else statements to keep the level of nesting low and do early return yet Scala doesn't allow that.

(I am aware that I should flatMap that shit though in some cases I just want a simple if not foo then throw exception line. And continue with the next block until I return something.)

So you either have to create if-else-nesting beats or use pattern matching. The latter seems overly complicated for this use case (though it has its moments).

I know that I can make the return explicit yet the linter warns against that. It feels so verbose and I currently do not see any benefits and would argue that the code becomes both harder to read and maintain.

Comments
  • 3
    Yeah that's what I thought too about Scala not having return statements, sometimes making things easier makes them more complicated
  • 0
    This is the functional way I guess
  • 0
    No early returns?!
    No guards?!
    Deep nesting?!
    Ewwwww!
Add Comment