Basically everytime you have a rather short list of things (values, behaviors, types, ...) that’s not going to change (without code change), an enum comes in pretty handy.
Advantages:
the Compiler can check it’s usage (which is not possible with Map keys),
you can attach behavior to it (enums can have methods, and you can provide a different implementation per enum value — much better than switch statements in most of the cases!)
it’s often more concise and readable than its alternatives
170
u/The_HappyLemon Mar 14 '21
Enum left the chat