diff options
author | Martin Odersky <odersky@gmail.com> | 2009-01-28 19:12:43 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2009-01-28 19:12:43 +0000 |
commit | 0606aa4755cc5261645e075176946fc16945561d (patch) | |
tree | 8089dfd63046d94b3a4246c351d440f4f735bdc1 | |
parent | 1898ae130752be2c24b6a92bee417766a52b00f5 (diff) | |
download | scala-0606aa4755cc5261645e075176946fc16945561d.tar.gz scala-0606aa4755cc5261645e075176946fc16945561d.tar.bz2 scala-0606aa4755cc5261645e075176946fc16945561d.zip |
break and continue now both go to a breakable b...
break and continue now both go to a breakable block.
-rwxr-xr-x | src/library/scalax/util/control/Breaks.scala | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/library/scalax/util/control/Breaks.scala b/src/library/scalax/util/control/Breaks.scala index d5ca883b77..6c938950d4 100755 --- a/src/library/scalax/util/control/Breaks.scala +++ b/src/library/scalax/util/control/Breaks.scala @@ -5,21 +5,20 @@ object Breaks { private val breakException = new BreakException private class ContinueException extends RuntimeException private val continueException = new BreakException - def break { throw breakException } + + /** A block from which one can exit with a `break' and which can be resumed with a `continue'. */ def breakable(op: => Unit) { try { op } catch { case ex: BreakException => + case ex: ContinueException => breakable(op) } } + + /* Break from closest enclosing breakable block */ + def break { throw breakException } + + /* Continue with start of closest enclosing breakable block */ def continue { throw continueException } - def continuable(op: => Unit) { - try { - op - } catch { - case ex: ContinueException => - continuable(op) - } - } } |