Type Safely

Type Safely

Simplify ForEach By Creating The ForEachIterable Protocol

Daily Coding Tip 263

Type Safely's avatar
Type Safely
Mar 12, 2023
∙ Paid
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…

User's avatar

Continue reading this post for free, courtesy of Type Safely.

Or purchase a paid subscription.
© 2026 Type Safely · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture