Hacker News new | ask | show | jobs
by sethammons 779 days ago
Can someone help me understand why enums are needed? They only seem like sugar for reducing a few lines while writing. What cannot be achieved without them or what is really a pain point they solve? Maybe it is hard to have a constant with type information?
1 comments

The original enum are just enumerated integer constants.

What people want "the ability to express enums with an associated value", I think we should invent a new term.

The term you're looking for is ADT - Algebraic Data Types

https://en.wikipedia.org/wiki/Algebraic_data_type

We did: Sum types.