The Scala package object | Contents |
Here are the most important definitions in this package object. As you can see, the main purpose of this object is to make a number of often-used definitions nested in subpackages available from the scala package. In this way, we distinguish convenience of access from logical structure. For instance, the List type is used so often that it makes sense to put it in the scala package thereby making it accessible without an import or name qualification. On the other hand, List is an immutable collection class, so it belongs logically in package scala.collection.immutable. Using package objects, one can have both a logical structure and fast access.
package object scala {
// Type and value aliases for collection classes
type TraversableOnce[+A] = scala.collection.TraversableOnce[A]
type Traversable[+A] = scala.collection.Traversable[A]
val Traversable = scala.collection.Traversable
type Iterable[+A] = scala.collection.Iterable[A]
val Iterable = scala.collection.Iterable
type Seq[+A] = scala.collection.Seq[A]
val Seq = scala.collection.Seq
type IndexedSeq[+A] = scala.collection.IndexedSeq[A]
val IndexedSeq = scala.collection.IndexedSeq
type Iterator[+A] = scala.collection.Iterator[A]
val Iterator = scala.collection.Iterator
type BufferedIterator[+A] = scala.collection.BufferedIterator[A]
type List[+A] = scala.collection.immutable.List[A]
val List = scala.collection.immutable.List
val Nil = scala.collection.immutable.Nil
type ::[A] = scala.collection.immutable.::[A]
val :: = scala.collection.immutable.::
type Stream[+A] = scala.collection.immutable.Stream[A]
val Stream = scala.collection.immutable.Stream
val #:: = scala.collection.immutable.Stream.#::
type Vector[+A] = scala.collection.immutable.Vector[A]
val Vector = scala.collection.immutable.Vector
type StringBuilder = scala.collection.mutable.StringBuilder
type Range = scala.collection.immutable.Range
val Range = scala.collection.immutable.Range
// Numeric types which were moved into scala.math.*
type BigDecimal = scala.math.BigDecimal
val BigDecimal = scala.math.BigDecimal
type BigInt = scala.math.BigInt
val BigInt = scala.math.BigInt
type Equiv[T] = scala.math.Equiv[T]
type Fractional[T] = scala.math.Fractional[T]
type Integral[T] = scala.math.Integral[T]
type Numeric[T] = scala.math.Numeric[T]
val Numeric = scala.math.Numeric
type Ordered[T] = scala.math.Ordered[T]
val Ordered = scala.math.Ordered
type Ordering[T] = scala.math.Ordering[T]
val Ordering = scala.math.Ordering
type PartialOrdering[T] = scala.math.PartialOrdering[T]
type PartiallyOrdered[T] = scala.math.PartiallyOrdered[T]
...
}
List.apply(1, 2, 3)
Next: Restrictions and things to come
The Scala package object | Contents |