Scala value classes

Value classes are a new mechanism in Scala to avoid allocating runtime objects. This is accomplished through the definition of new AnyVal subclasses. They were proposed in SIP-15. The following shows a very minimal value class definition:

class Wrapper(val underlying: Int) extends AnyVal

It has a single, public val parameter that is the underlying runtime representation. The type at compile time is Wrapper, but at runtime, the representation is an Int. A value class can define defs, but no vals, vars, or nested traitss, classes or objects.