diff options
author | Heather Miller <heather.miller@epfl.ch> | 2012-11-01 21:51:36 +0100 |
---|---|---|
committer | Heather Miller <heather.miller@epfl.ch> | 2012-11-02 15:00:19 +0100 |
commit | 71f02cd041e9c20d309686fcccf830a0f919f641 (patch) | |
tree | e219dbec99fe2cbb68f55f1ab2a45dee074ac488 /src/library-aux | |
parent | 59149579aec4b3d26a4cb849d80535a36b90ad30 (diff) | |
download | scala-71f02cd041e9c20d309686fcccf830a0f919f641.tar.gz scala-71f02cd041e9c20d309686fcccf830a0f919f641.tar.bz2 scala-71f02cd041e9c20d309686fcccf830a0f919f641.zip |
SI-6399 Adds API docs for Any and AnyVal
- Updates AnyVal docs to address value classes.
- Updates Any docs to address universal traits.
Diffstat (limited to 'src/library-aux')
-rw-r--r-- | src/library-aux/scala/Any.scala | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/library-aux/scala/Any.scala b/src/library-aux/scala/Any.scala index 031b7d9d8c..07a9ffa8d5 100644 --- a/src/library-aux/scala/Any.scala +++ b/src/library-aux/scala/Any.scala @@ -10,6 +10,25 @@ package scala /** 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 [[scala.AnyVal 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 [[http://docs.scala-lang.org/sips/pending/value-classes.html value classes guide]] for more + * details on the interplay of universal traits and value classes. */ abstract class Any { /** Compares the receiver object (`this`) with the argument object (`that`) for equivalence. |