Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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?


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: