The code below doesn't compile if I uncomment the line indicated. The compiler complains: "stable identifier required".
val Empty = Stream.empty
val a = Stream.range(0, 5)
a match {
// case Stream.empty => println("nope") <-- does not work
case Empty => println("compiles") <-- works
case _ => println("ok")
}
If I assign Stream.empty
to value Empty
first, it works, but it feels strange that you can't pattern match on such a fundamental value without such a hack.
Am I missing something?