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

How about putting Other at the top? You can convince yourself that the value zero (or one if you like) is reserved for unknown values.


This is what I tend to do. Because 0 is "default", it means "unspecified" in a lot of my API designs.


That's the Go approach, where every value is zeroed so it makes sense for enum values to have a 'none' or 'other' or 'unknown' value as the first value.

(note that Go doesn't have enums as a language feature, but you can use its const declaration to create enum-like constants)




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

Search: