Member-only story

Type Erasure in Swift

Get rid of that type information

Steven Curtis
4 min readSep 21, 2020
Photo by Mark Harpur on Unsplash

Difficulty: Beginner | Easy | Normal | Challenging
This article has been developed using Xcode 11.4.1, and Swift 5.2.2

This article is example laden, and shows how I’ve used Type Erasure in my production Apps. It should help if you wish to know what Type Erasure is and how you might apply it in your Swift code.

Prerequisites:

Terminology:

Type Erasure: Removing type information

When programming in Swift we have a type-safe language, that is Swift is strongly typed.

Now sometimes you might want to use type erasure, that is removing type information to find out why you might want to lose information in this way we have to think about protocol-oriented programming and specific implementations of the same…

Protocol-oriented programming — A real life need for Type Erasure

--

--

No responses yet