# Friday Q&A 2017-12-08: Type Erasure in Swift

DevFeed: [Friday Q&A 2017-12-08: Type Erasure in Swift](<https://devfeed.tech/articles/friday-q-a-2017-12-08-type-erasure-in-swift-30626.md>)

Original publisher: [Read original article](<http://www.mikeash.com/pyblog/friday-qa-2017-12-08-type-erasure-in-swift.html>)

Author: Mike Ash

Published: 2017-12-15T14:09:00Z

Content type: tutorial

Language: en

Sources: [Mike Ash](<https://devfeed.tech/sources/mike-ash.md>)

Topics: [Swift](<https://devfeed.tech/topics/swift.md>), [generics](<https://devfeed.tech/topics/generics.md>), [implementation](<https://devfeed.tech/topics/implementation.md>), [Library](<https://devfeed.tech/topics/library.md>)

Tags: [article](<https://devfeed.tech/tags/article.md>), [generics](<https://devfeed.tech/tags/generics.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [standard-library](<https://devfeed.tech/tags/standard-library.md>), [swift](<https://devfeed.tech/tags/swift.md>), [types](<https://devfeed.tech/tags/types.md>)

## AI overview

This tutorial explains type erasure in Swift, including why it is useful for hiding implementation details, preventing concrete types from spreading through a codebase, and allowing distinct types to interoperate. It discusses limitations involving generics and protocols with associated types, and describes using Any to erase an arbitrary type with a small complexity and runtime cost.

## Source excerpt

You might have heard the term type erasure. You might have even used type-erased types in the standard library, such as AnySequence. But what exactly is type erasure and how do you do it yourself? In this article, I'll explore type erasure, why you'd want it, and how to make it happen, a topic suggested by Lorenzo Boaro. (Read More)