Hacker News new | ask | show | jobs
by flyingchipmann 1891 days ago
The thing is enum and union type have different use cases. Union type cannot be used to check against incoming data. It's a lightweight type level feature. There is no way for compiler to identify the unknown data object from the network. Enum is essentially an object in memory which can be used in this case.