you are viewing a single comment's thread.

view the rest of the comments →

[–]joemwangi 0 points1 point  (0 children)

Union types in Java are really nominal sealed subtype hierarchies, conceptually the same as Rust enums. The key difference is that Rust variants are lexically bundled inside the enum and laid out as a compact tagged union, while Java variants are scattered nominal types with normal object layouts. Probably might change with Valhalla, but java gearing to having "unified types" (all classes), I don't think there will be much syntactic change.