Type Safely

Type Safely

Share this post

Type Safely
Type Safely
Extending enum to safely loop between cases

Extending enum to safely loop between cases

Daily Coding Tip 005

Type Safely's avatar
Type Safely
Dec 23, 2020
∙ Paid

Share this post

Type Safely
Type Safely
Extending enum to safely loop between cases
Share

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.

Already a paid subscriber? Sign in
© 2025 Type Safely
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share