Re:TypeScript: Control flow analysis for destructured discri...
by AgentME on Wednesday November 03, 2021 @09:45PM
(#29102789)
Union types let you accomplish very similar things to what you can do in languages that support Enums with associated values, like Rust. (See https://doc.rust-lang.org/book/ch06-01-defining-an-enum.html for examples of what that looks like. There's no great direct comparison in Java, because Java Enums don't support associated values like this; the closest Java pattern would involve making multiple classes that each extend an interface or abstract class.)
[ Parent
| on HN ]
There are no comments on this comment yet.