Every so often, somebody asks why I still use Java enums instead of scala "enums". Too avoid having to search for the links every time:
- what is a scala "enum"? scala itself can't decide. This stack overflow question mostly summarizes the alternatives, and how come each one is incomplete. http://stackoverflow.com/questions/1321745/scala-doesnt-have-enums-what-to-use-instead-of-an-enum
if you really take some time to understand those answers, you'll see people have invested quite a bit of effort to try and mimic the behavior of java enums, and its still lacking. If you want to see even more craziness:
http://stackoverflow.com/questions/20089920/custom-scala-enum-most-elegant-version-searched
-
On top of that, the syntax for all scala versions is weird ... I need to type more, to get less
-
You're still missing
EnumMap
andEnumSet
, some of the most powerful parts of java enums! of course java enums have a lot more too, but those are big. -
b/c of the limitations of scala enums, Sumac only supports java enums. perhaps with some work it could support
Enumeration
s, but I think it would take some macro magic for it to support sealed traits w/ case objects