summaryrefslogtreecommitdiff
path: root/src/library/scalax/util/control/Breaks.scala
blob: d5ca883b77a4d9b94cc871e021d09e00d7874482 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package scalax.util.control

object Breaks {
  private class BreakException extends RuntimeException
  private val breakException = new BreakException
  private class ContinueException extends RuntimeException
  private val continueException = new BreakException
  def break { throw breakException }
  def breakable(op: => Unit) {
    try {
      op
    } catch {
      case ex: BreakException =>
    }
  }
  def continue { throw continueException }
  def continuable(op: => Unit) {
    try {
      op
    } catch {
      case ex: ContinueException =>
	continuable(op)
    }
  }
}