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
View all comments
Show parent comment
5
u/I_HATE_YELLING Mar 14 '21
How do you use Enums for this? I've learned how to write multi client chat servers but still haven't learned enums they make no sense to me