2 ms·
This is correct given Scala's limitation: the only common supertype between Int and Option is Any. A language that supports union types (e.g. Ceylon) will type
by zak_mc_kracken 12y ago
This is correct given Scala's limitation: the only common supertype between Int and Option is Any.
A language that supports union types (e.g. Ceylon) will type this expression as Int|Option[Int], which is as specific as you can get.
- axiomabsolute 12y agoI believe Ceylon will actually further refine Int | Option[Int] to simply Option[Int]. Option[Int] is simply an alias to the type Int | Null, so Int | Option[Int] would become Int | Int | Null after replacement, which simplifies to Int | Null since Int | Int is equivalent to just Int.