Sunday, 16 August 2020

Scala: Unified Type System

 In Scala, all the values are instances of ‘Any’ class. 

AnyRef and AnyVal are the immediate subclasses of Any. AnyRef is the common ancestor for all the reference types, AnyVal is the common ancestor for all the value types.

 

Boolean, Byte, Char, Double, Long, Float, Int, Short, Unit are direct known subclasses of AnyVal.

 

Class AnyRef is the root class of all reference types. All types except the value types descend from this class. All collections, user-defined classes, String, and traits are derived from AnyRef.

Previous                                                    Next                                                    Home

No comments:

Post a Comment