Scala 2
API Specification

This document is the API specification for Scala 2.

Class Summary
`final` `case` | `class` :: [b] A non empty list characterized by a head and a tail.
`sealed` `abstract` | `class` All$ Dummy class which exist only to satisfy the JVM. It corresponds to `scala.All`. If such type appears in method signatures, it is erased to this one.
`sealed` `abstract` | `class` AllRef$ Dummy class which exist only to satisfy the JVM. It corresponds to `scala.AllRef`. If such type appears in method signatures, it is erased to this one.
`final` | `class` Array [A] This class represents polymorphic arrays. It is never instantiated.
| `class` Attribute A base class for attributes
| `class` BigInt
`case` | `class` Cell [T] A `Cell` is a generic wrapper which completely hides the functionality of the wrapped object. The wrapped object is accessible via the `elem` accessor method.
`abstract` | `class` Enumeration The class `Enumeration` provides the same functionality as the `enum` construct found in C-like languages like C++ or Java. Here is an example:
     object Main extends Application {

       object WeekDays extends Enumeration  {
         val Mon, Tue, Wed, Thu, Fri, Sat, Sun = Value
       }

       def isWorkingDay(d: WeekDays.Value) =
         ! (d == WeekDays.Sat || d == WeekDays.Sun)

       WeekDays filter (isWorkingDay) foreach { d => Console.println(d) }
     }
`sealed` `abstract` | `class` List [a] A class representing an ordered collection of elements of type `a`. This class comes with two implementing case classes `scala.Nil` and `scala.::` that implement the abstract members `isEmpty`, `head` and `tail`.
`final` | `class` MatchError
`final` | `class` NotDefinedError
`sealed` `abstract` | `class` Nothing$ Dummy class which exist only to satisfy the JVM. It corresponds to `scala.Nothing`. If such type appears in method signatures, it is erased to this one.
`sealed` `abstract` | `class` Null$ Dummy class which exist only to satisfy the JVM. It corresponds to `scala.Null`. If such type appears in method signatures, it is erased to this one.
`sealed` `abstract` | `class` Option [A] This class represents optional values. Instances of `Option` are either instances of case class `Some` or it is case object `None`.
`abstract` | `class` Responder [a] Instances of responder are the building blocks of small programs written in continuation passing style. By using responder classes in for comprehensions, one can embed domain-specific languages in Scala while giving the impression that programs in these DSLs are written in direct style.
| `class` SerialVersionUID Attribute for specifying the static SerialVersionUID field of a serializable class
`final` `case` | `class` Some [A] Class `Some[A]` represents existing values of type `A`.
`final` `case` | `class` Symbol Instances of `Symbol` can be created easily with Scala's built-in quote mechanism. For instance, the Scala term `'mysym` will invoke the constructor of the `Symbol` class in the following way: `new Symbol("mysym")`. .
`case` | `class` Tuple1 [T1]
`case` | `class` Tuple2 [T1, T2]
`case` | `class` Tuple3 [T1, T2, T3]
`case` | `class` Tuple4 [T1, T2, T3, T4]
`case` | `class` Tuple5 [T1, T2, T3, T4, T5]
`case` | `class` Tuple6 [T1, T2, T3, T4, T5, T6]
`case` | `class` Tuple7 [T1, T2, T3, T4, T5, T6, T7]
`case` | `class` Tuple8 [T1, T2, T3, T4, T5, T6, T7, T8]
`case` | `class` Tuple9 [T1, T2, T3, T4, T5, T6, T7, T8, T9]
| `class` cloneable An attribute that designates the class to which it is applied as cloneable
| `class` remote
| `class` serializable An attribute that designates the class to which it is applied as serializable
| `class` throws Attribute for specifying the exceptions thrown by a method. Example:
     class Reader(fname: String) {
       private val in =
         new BufferedReader(new FileReader(fname))
       [throws(classOf[IOException])]
       def read() = in.read()
     }
| `class` transient
| `class` volatile

Trait Summary
`abstract` | `trait` Application The `Application` class can be used to quickly turn objects into executable programs. Here is an example:
      object Main extends Application {
        Console.println("Hello World!")
      }
Here, object `Main` inherits the `main` method of `Application`. The body of the `Main` object defines the main program. This technique does not work if the main program depends on command-line arguments (which are not accessible with the technique presented here). It is possible to time the execution of objects that inherit from class `Application` by setting the global scala.time property. Here is an example for benchmarking object `Main`:
      java -Dscala.time Main
`abstract` | `trait` BufferedIterator [A] Buffered iterators are iterators which allow to inspect the next element without discarding it.
`abstract` | `trait` ByNameFunction [A, B] A partial function of type `PartialFunction[A, B]` is a unary function where the domain does not include all values of type `A`. The function `isDefinedAt` allows to test dynamically, if a value is in the domain of the function.
`abstract` | `trait` CountedIterator [A] Counted iterators keep track of the number of elements seen so far
`abstract` | `trait` Function0 [R] Function with no parameters. In the following example the definition of `currentSeconds` is a shorthand for the anonymous class definition `anonfun0`:
     object Main extends Application {

       val currentSeconds = () => System.currentTimeMillis() / 1000L

       val anonfun0 = new Function0[Long] {
         def apply(): Long = System.currentTimeMillis() / 1000L
       }

       Console.println(currentSeconds())
       Console.println(anonfun0())
     }
`abstract` | `trait` Function1 [T0, R] Function with 1 parameter. In the following example the definition of `succ` is a shorthand for the anonymous class definition `anonfun1`:
     object Main extends Application {

       val succ = (x: Int) => x + 1

       val anonfun1 = new Function1[Int, Int] {
         def apply(x: Int): Int = x + 1
       }

       Console.println(succ(0))
       Console.println(anonfun1(0))
     }
`abstract` | `trait` Function2 [T0, T1, R] Function with 2 parameters. In the following example the definition of `max` is a shorthand for the anonymous class definition `anonfun2`:
     object Main extends Application {

       val max = (x: Int, y: Int) => if (x < y) y else x

       val anonfun2 = new Function2[Int, Int, Int] {
         def apply(x: Int, y: Int): Int = if (x < y) y else x
       }

       Console.println(max(0, 1))
       Console.println(anonfun2(0, 1))
     }
`abstract` | `trait` Function3 [T0, T1, T2, R] Function with 3 parameters
`abstract` | `trait` Function4 [T0, T1, T2, T3, R] Function with 4 parameters
`abstract` | `trait` Function5 [T0, T1, T2, T3, T4, R] Function with 5 parameters
`abstract` | `trait` Function6 [T0, T1, T2, T3, T4, T5, R] Function with 6 parameters
`abstract` | `trait` Function7 [T0, T1, T2, T3, T4, T5, T6, R] Function with 7 parameters
`abstract` | `trait` Function8 [T0, T1, T2, T3, T4, T5, T6, T7, R] Function with 8 parameters
`abstract` | `trait` Function9 [T0, T1, T2, T3, T4, T5, T6, T7, T8, R] Function with 9 parameters
`abstract` | `trait` Iterable [A] Collection classes mixing in this class provide a method `elements` which returns an iterator over all the elements contained in the collection.
`abstract` | `trait` IterableProxy [A] This class implements a proxy for iterable objects. It forwards all calls to a different iterable object.
`abstract` | `trait` Iterator [A] Iterators are data structures that allow to iterate over a sequence of elements. They have a `hasNext` method for checking if there is a next element available, and a `next` method which returns the next element and discards it from the iterator.
`abstract` | `trait` Ordered [a] A class for totally ordered data. Note that since version 2006-07-24 this class is no longer covariant in a.
`abstract` | `trait` PartialFunction [A, B] A partial function of type `PartialFunction[A, B]` is a unary function where the domain does not include all values of type `A`. The function `isDefinedAt` allows to test dynamically, if a value is in the domain of the function.
`abstract` | `trait` PartiallyOrdered [a] A class for partially ordered data.
`abstract` | `trait` Product The trait `Product` defines access functions for instances of products, in particular case classes.
`abstract` | `trait` Product0 Product0 is a cartesian product of 0 components
`abstract` | `trait` Product1 [T1] Product1 is a cartesian product of 1 components
`abstract` | `trait` Product2 [T1, T2] Product2 is a cartesian product of 2 components
`abstract` | `trait` Product3 [T1, T2, T3] Product3 is a cartesian product of 3 components
`abstract` | `trait` Product4 [T1, T2, T3, T4] Product4 is a cartesian product of 4 components
`abstract` | `trait` Product5 [T1, T2, T3, T4, T5] Product5 is a cartesian product of 5 components
`abstract` | `trait` Product6 [T1, T2, T3, T4, T5, T6] Product6 is a cartesian product of 6 components
`abstract` | `trait` Product7 [T1, T2, T3, T4, T5, T6, T7] Product7 is a cartesian product of 7 components
`abstract` | `trait` Product8 [T1, T2, T3, T4, T5, T6, T7, T8] Product8 is a cartesian product of 8 components
`abstract` | `trait` Product9 [T1, T2, T3, T4, T5, T6, T7, T8, T9] Product9 is a cartesian product of 9 components
`abstract` | `trait` Proxy This class implements a simple proxy that forwards all calls to methods of class `Any` to another object `self`. Please note that only those methods can be forwarded that are overridable and public.
`abstract` | `trait` ScalaObject
`abstract` | `trait` Seq [A] Class `Seq[A]` represents finite sequences of elements of type `A`.
`abstract` | `trait` SeqProxy [A] Class `Seq[A]` represents finite sequences of elements of type `A`.
`abstract` | `trait` Stream [a] The class `Stream` implements lazy lists where elements are only evaluated when they are needed. Here is an example:
     object Main extends Application {

       def from(n: Int): Stream[Int] =
         Stream.cons(n, from(n + 1))

       def sieve(s: Stream[Int]): Stream[Int] =
         Stream.cons(s.head, sieve(s.tail filter { x => x % s.head != 0 }))

       def primes = sieve(from(2))

       primes take 10 print
     }

Object Summary
| `object` Array This object ...
| `object` BigInt
| `object` Console The `Console` object implements functionality for printing Scala values on the terminal. There are also functions for reading specific values. `Console` also defines constants for marking up text on ANSI terminals.
| `object` Iterable This object ...
| `object` Iterator The `Iterator` object provides various functions for creating specialized iterators.
| `object` List This object provides methods for creating specialized lists, and for transforming special kinds of lists (e.g. lists of lists).
| `object` MatchError This class implements errors which are thrown whenever an object doesn't match any pattern of a pattern matching expression.
`case` | `object` Nil The empty list.
`case` | `object` None This case object represents non-existent values.
| `object` Predef The `Predef` object provides definitions that are accessible in all Scala compilation units without explicit qualification.
| `object` Responder This object contains utility methods to build responders.
| `object` Seq
| `object` Stream The object `Stream` provides helper functions to manipulate streams.