Data Types
In the following lesson, you will be introduced to Scala's type hierarchy.
Introduction
In Scala, every value has a type and each type is part of a type hierarchy. In a type hierarchy, the more generic types are at the top and as you go lower in the hierarchy, the types get more specific, i.e., have more requirements. Each type has a requirement of its own along with the requirements of all the types above it in the hierarchy.
Scala Type Hierarchy
At the top of the type hierarchy in Scala, we have type Any
. It is the super-type and defines certain universal methods such as equals
, hashCode
, and toString
.
Any
has two subclasses, namely AnyVal
and AnyRef
. AnyVal
...