3 ms·
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 chec
by LambdaComplex 3y ago
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.
- deleted 3y ago[deleted]
- euroderf 3y agoAs a workaround, a list in a DB combined with a foreign key constraint. Ugly, yes.