- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
How do you code "break" and "continue"?
Created by admin on 2008-07-28.
Updated: 2009-06-02, 21:15
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
.