Type Safely

Type Safely

Using a Switch and ForEach To Cast From an [Any] Array

Daily Coding Tip 187

Millie Sturgeon's avatar
Millie Sturgeon
Oct 03, 2022
∙ Paid
two gray switch panels
Photo by Karim MANJRA on Unsplash

I’m not used to using a switch to deal with data that could be of any type.

I’m a big fan of type safety, and that means I don’t like using the Any type. However, I did find it interesting that in the official Swift documentation (the open source project, not the Apple API) there are ways to cast that I hadn’t used befor…

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