what are reasons to use enum classes instead of se...
# getting-started
h
what are reasons to use enum classes instead of sealed class? so far, i know that: *enums are simpler syntax *enums have a (final😡) name property *enums have ordinals Are sealed classes more space and time costly? Should I avoid using them over enums if all i want is to define the name property myself?
t
you can instantiate sealed classes but you cannot instantiate enums
so if you do not want to instiate them you should use enums. if you want to make instance you cannot use enums
h
okay so what if you're only extending the sealed class with objects?
then you should for no reason use a sealed class?
t
i'd guess that they are slightly more performant then `object`s of a sealed class. also enums also provide an implementation of
Comperable
i don't see a reason to not use an enum, if you could
h
yeah, due to having ordinals
e
I really like that they can have different parameters in the constructor. For some states, it helps a lot. 🙂 https://github.com/igorescodro/alkaa/commit/332731a897e6f6fdb9cd685a51f7574e1c6252af#diff-b223a26e0867290ee4ae8eb2cd228c49R28
👍 1