Type Safely

Type Safely

Share this post

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

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

Share this post

Type Safely
Type Safely
Using a Switch and ForEach To Cast From an [Any] Array
Share
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…

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