Scala Data Types
Scala’s unified type system
Any
is the super type- Defines methods like -
equals
,hashCode
,toString
- Defines methods like -
AnyVal
represents value types.- Double
- Float
- Long
- Int
- Short
- Byte
- Char
- Unit - Only one instance can be there -
()
- Boolean
AnyRef
represent refernce types likeList
Nothing
is subclass for all value types.Null
is subclass for all reference types. Should not be used in Scala code.
Type Casting
Type casting is unidirectional
Source - https://docs.scala-lang.org/tour/unified-types.html