Unified Types is an overview of Scala’s types and classes at a very high level.
All Scala values are objects; there is no formal “primitive” type as there is in Java. However, there is a distinction in the main object tree.
Every object is a subtype of
Any, however in practice, most objects will be a direct subtype of
AnyVal is a superclass for the types that, in Java, are considered “primitive” (that being things like
float). Further, all classes implicitly extend scala.ScalaObject (which is a trait) and AnyRef (yes, there is multiple inheritance). Finally, classes you can access from the Java runtime do not extend scala.ScalaObject, but just extend AnyRef.
My Thoughts on this Feature
Thank GOD we don’t need Java’s stupid primitive types any more (even though they are actually still there, since this is the JVM and all). However, I find the concepts of
null less than intuitive. Stuff like this just makes me scratch my head. Especially
Nil being the empty list. What’s so wrong with
Last Updated 09/21/2009 at 03:24:13 PM by davecblog comments powered by Disqus
Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.