Associated values

Enum cases can include different types in Swift. When cases are declared to be of different types like this, we speak of an enum having associated values.

In this section, we will look at two valuable use cases for associated values:

  • Using an enum to group together different data types
  • Using an enum to create multiple distinct types from a single type