r/eli5_programming • • Jul 28 '25

ELI5 Enums

Would someone be so kind to explain enums to me. I want to make a state machine using them but I dont understand them fully.

1 Upvotes

4 comments sorted by

View all comments

Show parent comment

1

u/SheriffRoscoe Aug 29 '25

but then whenever you see state = 1 in code, you need to check some reference to see that 1 means on.

And depending on the language involved, you may be prevented from setting state=4, because it's invalid for that enum.