Question

The Scala-Lang docs say:

Long, a 64-bit signed integer (equivalent to Java's long primitive type) is a subtype of scala.AnyVal. Instances of Long are not represented by an object in the underlying runtime system.

Java has a long (primitive) and Long (boxed).

Does Scala have aboxed version of this primitive?

Was it helpful?

Solution

Scala boxes and unboxes silently, so there is just one class. The compiler will try to use primitive values when it can, and uses boxed values when it can't. This happens using the Value Class mechanisms, which are classes that have specific properties that allow the compiler to take them apart when possible.

More on value classes: http://docs.scala-lang.org/overviews/core/value-classes.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top