I see from Scala hierarchy that AnyVal
is super type for scala.Unit
, Boolean
, Char
and other Number
types.
scala> val list1 = List((), 1 )
list: List[AnyVal] = List((), 1) // I see this is valid when compared with hierarchy tree.
scala> val list2 = List(Unit, 1 )
list: List[Any] = List(object scala.Unit, 1) // Why???
I see list1
is of type AnyVal
where as list2
is of type Any
, even though they have same data (I assume).
Is ()
not same as Scala.Unit
? What am I missing here?