CaseIterable

enum Season: CaseIterable {
  case winter
  case spring
  case summer
  case falls
}
for season in Season.allCases {
  print(season)
}

Add conformance to the CaseIterable protocol to access the allCases property, which returns an array of all cases of the enumeration

Comments