Consider this code:
var unit: Unit = null
unit: Unit = ()
a) Why am I allowed to assign null to a value class? (see §12.2.3)
b) Why does the null get converted to ()?
Consider this code:
var unit: Unit = null
unit: Unit = ()
a) Why am I allowed to assign null to a value class? (see §12.2.3)
b) Why does the null get converted to ()?
Copyright © 2021 Jogjafile Inc.
From the scala specification section 6.26.1:
In other words, your code is equivalent to
The
nullisn't converted -- it's merely ignored and replaced by(), the predefinedUnitvalue.