boundary (original) (raw)

scala.util.boundary

A boundary that can be exited by break calls. boundary and break represent a unified and superior alternative for the scala.util.control.NonLocalReturns and scala.util.control.Breaks APIs. The main differences are:

Example usage:

import scala.util.boundary, boundary.break

def firstIndex[T](xs: List[T], elem: T): Int =
 boundary:
   for (x, i) <- xs.zipWithIndex do
     if x == elem then break(i)
   -1

Attributes

Source

boundary.scala

Graph

Supertypes

Self type

Members list

User code should call break.apply instead of throwing this exception directly.

User code should call break.apply instead of throwing this exception directly.

Attributes

Source

boundary.scala

Supertypes

Labels are targets indicating which boundary will be exited by a break.

Labels are targets indicating which boundary will be exited by a break.

Attributes

Source

boundary.scala

Supertypes

Run body with freshly generated label as implicit argument. Catch any breaks associated with that label and return their results instead of body's result.

Run body with freshly generated label as implicit argument. Catch any breaks associated with that label and return their results instead of body's result.

Attributes

Source

boundary.scala

Abort current computation and instead return value as the value of the enclosing boundary call that created label.

Abort current computation and instead return value as the value of the enclosing boundary call that created label.

Attributes

Source

boundary.scala

Abort current computation and instead continue after the boundary call that created label.

Abort current computation and instead continue after the boundary call that created label.

Attributes

Source

boundary.scala

In this article