Hacker News new | past | comments | ask | show | jobs | submit login

C# enums are strictly worse: they’re C enums, meaning they’re no safer than integers, but they don’t tell you about that.

Go at least does not pretend it has anything like enums or sum types, and that is to its credit. You create a Go integer type, it’s flagrantly shit, but it’s not subtle about it.




C# enums explicitly tell you that and it is well documented. You have easy Enum.IsDefined(enumValue) as well as Enum.GetName(enumValue) which work exactly as advertised. Switches on enum values will tell you to handle the default case too.

They are not ideal by modern standards when you look at Rust. But to state that they are worse than Go's is a new and I can't find a way in which this kind of statement would defensible.




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

Search: