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

Your #2 is wrong (sorry). Enums in most mainstream languages don't "limit"; they merely specify known values. Unknown values are still possible. For a type-safe enum, see discriminated union.


Can you give some examples other than C, C++, and C# where this is true? Most languages either don't have them as definable types, are C based and therefore map them to integers, or actually limit values.

AFAIK, python, java, rust, ocaml, haskell, and swift all have enums that actually limit values.





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

Search: