Learning Scala Programming
上QQ阅读APP看书,第一时间看更新

AnyRef

The AnyRef class represents all values that are/can be represented as objects in the underlying runtime system. It includes all user-defined classes that explicitly do not inherit from AnyVal. Some standard reference classes are String, Tuple, Function, and Array. The Scala compiler either provides syntactic sugar for them, or generates special code at the time of compilation for their operations. We've already seen a bit of syntactic sugar such as Tuple2, which can be represented as (A, B) where A and B are type parameters. An applied form of this Tuple2 can be (String and Int). In Scala, we represent this as Tuple2[String, Int].