Although an enumeration is not an array, it is sometimes necessary to iterate over the cases that it contains. In my enumeration I have the names of three fruits: apple
, banana
and pear
. My enum conforms to the CaseIterable
protocol, and this allows me to have access to an array of my cases.
What if I want to change from my current case to the next case…
Keep reading with a 7-day free trial
Subscribe to Type Safely to keep reading this post and get 7 days of free access to the full post archives.