Type Safely

Type Safely

Share this post

Type Safely
Type Safely
Simplify ForEach By Creating The ForEachIterable Protocol
Copy link
Facebook
Email
Notes
More

Simplify ForEach By Creating The ForEachIterable Protocol

Daily Coding Tip 263

Type Safely's avatar
Type Safely
Mar 12, 2023
∙ Paid

Share this post

Type Safely
Type Safely
Simplify ForEach By Creating The ForEachIterable Protocol
Copy link
Facebook
Email
Notes
More
Share
assorted-color opened umbrellas
Photo by Ricardo Resende on Unsplash

When applied to an enum, this ForEachIterable protocol has a default implementation that works.

In other words, there is built-in conformance to CaseIterable for enums as long as you declare conformance. There are no stubs to be added after an error complaining that you do not conform to CaseIterable. All this protoco…

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

Copy link
Facebook
Email
Notes
More