Class Any
is the root of the Scala class hierarchy.
Class Any
is the root of the Scala class hierarchy. Every class in a Scala
execution environment inherits directly or indirectly from this class.
Starting with Scala 2.10 it is possible to directly extend Any
using universal traits.
A universal trait is a trait that extends Any
, only has def
s as members, and does no initialization.
The main use case for universal traits is to allow basic inheritance of methods for value classes. For example,
trait Printable extends Any { def print(): Unit = println(this) } class Wrapper(val underlying: Int) extends AnyVal with Printable val w = new Wrapper(3) w.print()
See the Value Classes and Universal Traits for more details on the interplay of universal traits and value classes.
Nothing
is - together with scala.Null - at the bottom of Scala's type hierarchy.
Nothing
is - together with scala.Null - at the bottom of Scala's type hierarchy.
Nothing
is a subtype of every other type (including scala.Null); there exist
no instances of this type. Although type Nothing
is uninhabited, it is
nevertheless useful in several ways. For instance, the Scala library defines a value
scala.collection.immutable.Nil of type List[Nothing]
. Because lists are covariant in Scala,
this makes scala.collection.immutable.Nil an instance of List[T]
, for any element of type T
.
Another usage for Nothing is the return type for methods which never return normally. One example is method error in scala.sys, which always throws an exception.
Null
is - together with scala.Nothing - at the bottom of the Scala type hierarchy.
Null
is - together with scala.Nothing - at the bottom of the Scala type hierarchy.
Null
is a subtype of all reference types; its only instance is the null
reference.
Since Null
is not a subtype of value types, null
is not a member of any such type. For instance,
it is not possible to assign null
to a variable of type scala.Int.
A library that provides both asynchronous and synchronous messaging to allow for concurrent programming without explicit synchronization.
A library that provides both asynchronous and synchronous messaging to allow for concurrent programming without explicit synchronization.
A detailed guide for the actors library is available http://docs.scala-lang.org/overviews/core/actors.html.
A starting point for using the actors library would be scala.actors.Reactor, scala.actors.ReplyReactor, or scala.actors.Actor or their companion objects.
As of release 2.10.1, replaced by akka.actor
package. For migration of existing actors refer to the Actors Migration Guide.