Module 02 Β· Kotlin, One Level Deeper β Lesson 3 of 5 Β· ~12 min
Enums & Sealed Interfaces: A Fixed Set of Choices
A fixed set of choices
A PawWalk user is an owner or a walker. Not both, not "ownerr" with a typo, not some surprise third thing. When a value can only be one of a known, fixed set of choices, Kotlin gives you the enum class.
You declare the choices as entries. A value of the type is exactly one entry: val status = BookingStatus.PENDING.