3 ms·
> "I haven't checked after release, how is Scala 3 smart-casting now? E.g. Kotlin and Typescript convert a T? to a T inside an if(t != null) branch, and Scala's
by gavinray 5y ago
> "I haven't checked after release, how is Scala 3 smart-casting now? E.g. Kotlin and Typescript convert a T? to a T inside an if(t != null) branch, and Scala's left much to be desired when I checked."
See: https://docs.scala-lang.org/scala3/reference/other-new-features/explicit-nulls.html#flow-typing https://docs.scala-lang.org/scala3/reference/other-new-featu...
It works perfectly well in a number of ways (IE, you can use "=="/"!=" null, use a "match")
https://scastie.scala-lang.org/s853XsLoQEKTVosebJHelA https://scastie.scala-lang.org/s853XsLoQEKTVosebJHelA
Kotlin is still a better experience when interacting with Java because of inbuilt interop with Java types like "List" though, in my opinion.
In Scala you need to use ".asScala", ".asJava" etc.