Introduction to Enum Classes
Learn how to define and use enum classes and access enum properties and functions.
We'll cover the following...
We'll cover the following...
In this chapter, we’re going to introduce the concept of enum classes. Let’s start with an example. Suppose that we’re implementing a payment method that has to support three possible options:
Cash payment
Card payment
Bank transfer
Using enum values
The most basic way to represent a fixed set of values in Kotlin is an enum class. Inside its body, we list all the values, divided by a comma. ...