Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> in Scala no-one uses "return" any more

Huh??? Does Scala even have a "return" statement? I can't find it in the docs.



There is: http://scala-lang.org/files/archive/spec/2.11/06-expressions...

The general consensus is: don't use it.


Ah, there it is. OK, so I'm still confused.

> you can get the same functionality (in a better / more consistent way) using library types

RETURN is a control construct. How do you emulate a control construct using types?


In a language with first-class functions, control constructs can be replaced by polymorphic methods - see smalltalk for the ultimate version of this. In scala the idiomatic way to do "short-circuit the rest of this in some cases" is usually for/yield with a type like scalaz's \/.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: