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

Having "type MyType int" and defining a bunch of constants isn't a great replacement for enums. Yeah, it "works," but it still lets the developer forget to check for a possible variant, or you could have an underlying int that doesn't correspond to a valid variant.

The addition of enums would move all these runtime checks to compile time.



As a workaround, a list in a DB combined with a foreign key constraint. Ugly, yes.




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

Search: