This page is no longer maintained — Please continue to the home page at www.scala-lang.org

How do you code "break" and "continue"?

These keywords are not included in Scala 2.7, and must be implemented in a different way. For break, the simplest thing to do is to divide your code into smaller methods and use the return to exit early. For continue, a simple approach is to place the skipped-over parts of a loop into an if.

Scala 2.8 will include break, but not continue.

 

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland