Using data structures like Either enhanced with kotlin's smart casts come at least close but for now you wont be able to have real union types, only distinct union types. Meaning, you can do
Copy code
val e: Either<String, Int> = Left("hello")
e = Right(1);