trait NotNull {}
I am trying to understand how this trait can guarantee that something is not null, and I cannot understand:
def main(args: Array[String]) { val i = List(1, 2) foo(i)
and
val i = new Object with NotNull
Obviously, there is some special compiler handling, because it compiles:
trait MyTrait {} def main(args: Array[String]) { val i: MyTrait = null println(i) }
If this is not the case:
def main(args: Array[String]) { val i: NotNull = null
EDIT: there is nothing about it I can find in programming in Scala
oxbow_lakes Feb 25 2018-10-25T00 : 00Z
source share