I’m using a state machine, and the code’s getting really verbose when testing against a large number of possible states.
enum Mood {
HAPPY, SAD, CALM, SLEEPY, OPTIMISTIC, PENSIVE, ENERGETIC;
}
Is there any way to do this:
if (currentMood == (HAPPY | OPTIMISTIC | ENERGETIC) {}
Instead of this:
if (currentMood == HAPPY || currentMood == OPTIMISTIC || currentMood == ENERGETIC) {}
Or would it be better to stick with integers and flags in this case?
Maybe use something like EnumSet?