Questo è in realtà spiegato esplicitamente nella Specifica della lingua di Scala . Per favore, dai un'occhiata a Sezione 6.3 Il Null value , che dice questo:
The null value is of type scala.Null, and thus conforms to every reference type.
It denotes a reference value which refers to a special null object.
This object implements methods in class scala.AnyRef as follows:
- […]
-
asInstanceOf[T] returns the default value of type T.
Il valore predefinito per qualsiasi sottotipo di AnyRef è null , il valore predefinito per i sottotipi di AnyVal è specifico del tipo, ma di solito un valore neutro specifico del tipo, come 0 per Int , Long , ecc., 0.0 per Float e Double e false per Boolean .