3 ms·
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 w
by sethammons 3y 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?
- brainzap 3y agoThe 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.
- masterj 3y agoThe term you're looking for is ADT - Algebraic Data Types https://en.wikipedia.org/wiki/Algebraic_data_type https://en.wikipedia.org/wiki/Algebraic_data_type
- randomdata 3y agoWe did: Sum types.