Is there currently a way to remove or deprecate co...
# language-evolution
h
Is there currently a way to remove or deprecate comparison for enum classes? I have an enum class that I don't want comparison operators being used on, and instead all possibilities should be listed explicitly, but I can't think of a way this can currently be done. If not, I think it would be nice to have.
k
I don't think there is currently any way to disable the comparison operators at compile time (since enums are subclasses of
Enum
which implements
Comparable
). As a workaround, instead of enums you can create classes implementing a sealed interface.
h
Yeah those just don't serialize nearly as well, which is more important in my case.
No enums are serialized by name
e