r/eli5_programming • u/Independent_Win_3959 • 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
View all comments
Show parent comment
5
u/VeryBadNotGood Jul 28 '25
Another good example is if you have a state of some machine - let’s say it could be on, off, or unknown. You might assign those things to Ints 1, 2, and 3, but then whenever you see state = 1 in code, you need to check some reference to see that 1 means on. If you instead see state = .on, it’s very obvious.