Type erasure in Swift
4 min readApr 8, 2024
What is type erasure?
Type erasure is a powerful technique used in modern programming languages to abstract away the specific types of objects and to provide a more generic interface for working with related types. It allows programmers to write code that can be reused across multiple types, without the need to define separate implementations for each type.
This technique is commonly used in languages such as Swift and Kotlin, but the concept is applicable to many other programming languages as well. In this article, we’ll explore what type erasure is…