Packages

  • package root

    This is the documentation for the Scala standard library.

    This is the documentation for the Scala standard library.

    Package structure

    The scala package contains core types like Int, Float, Array or Option which are accessible in all Scala compilation units without explicit qualification or imports.

    Notable packages include:

    Other packages exist. See the complete list on the right.

    Additional parts of the standard library are shipped as separate libraries. These include:

    Automatic imports

    Identifiers in the scala package and the scala.Predef object are always in scope by default.

    Some of these identifiers are type aliases provided as shortcuts to commonly used classes. For example, List is an alias for scala.collection.immutable.List.

    Other aliases refer to classes provided by the underlying platform. For example, on the JVM, String is an alias for java.lang.String.

    Definition Classes
    root
  • package scala

    Core Scala types.

    Core Scala types. They are always available without an explicit import.

    Definition Classes
    root
  • package util
    Definition Classes
    scala
  • package control
    Definition Classes
    util
  • class Breaks extends AnyRef

    Provides the break control abstraction.

    Provides the break control abstraction.

    The break method uses a ControlThrowable to transfer control up the stack to an enclosing breakable.

    It is typically used to abruptly terminate a for loop, but can be used to return from an arbitrary computation.

    Control resumes after the breakable.

    If there is no matching breakable, the BreakControl thrown by break is handled in the usual way: if not caught, it may terminate the current Thread.

    BreakControl carries no stack trace, so the default exception handler does not print useful diagnostic information; there is no compile-time warning if there is no matching breakable.

    A catch clause using NonFatal is safe to use with break; it will not short-circuit the transfer of control to the enclosing breakable.

    A breakable matches a call to break if the methods were invoked on the same receiver object, which may be the convenience value Breaks.

    Example usage:

    val mybreaks = new Breaks
    import mybreaks.{break, breakable}
    
    breakable {
      for (x <- xs) {
        if (done) break()
        f(x)
      }
    }

    Calls to break from one instance of Breaks will never resume at the breakable of some other instance.

    Any intervening exception handlers should use NonFatal, or use Try for evaluation:

    val mybreaks = new Breaks
    import mybreaks.{break, breakable}
    
    breakable {
      for (x <- xs) Try { if (quit) break else f(x) }.foreach(println)
    }
    Definition Classes
    control
  • TryBlock

sealed trait TryBlock[T] extends AnyRef

Source
Breaks.scala
Linear Supertypes
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. TryBlock
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Abstract Value Members

  1. abstract def catchBreak(onBreak: => T): T