Dienstag, 1. Mai 2012

The Scala object model: scala.Any, scala.AnyVal, scala.AnyRef

The Scala object model: scala.Any, scala.AnyVal, scala.AnyRef

excerpted from : An Overview of the Scala Programming Language, Second Edition

1. Every value is an object and every operation is a message send.

2. Every class in Scala inherits from class Scala.Any.  Subclasses of Any fall into two categories: the value classes which inherit from scala.AnyVal and the reference classes which inherit from scala.AnyRef.

3. Every primitive Java type name corresponds to a value class, and is mapped to it by a predefined type alias.

4. In a Java environment, AnyRef is identified with the root class java.lang.Object. An instance of a reference class is usually implemented as a pointer to an object stored in the program heap. An instance of a value class is usually represented directly, without indirection through a pointer.

聖鬥士星矢- 冥王十二宮篇 13 插歌

Keine Kommentare: