My previous post was about a DIY implementation of union types in Scala.
I have been doing Kotlin recently (also awesome), and just got around to looking into Scala 3... And lo and behold, they added union types -- nice!
They also pulled null out of Any and use union types to model nullable types such as Any | null or String | null, etc.
This is similar to how Kotlin and C# model nullable types, although they use a question mark suffix (which is actually really clean and lends itself to cool things like the elvis operator).
And they cleaned up extension methods (now more like Kotlin and C#) so they don't go through the convoluted implicits (which have now been simplified).
These are breaking changes and require opt-in, and there are more changes, but definitely a worthwhile upgrade that I look forward to using.
No comments:
Post a Comment