# Type-Erasing in Swift | AnyView behind the scenes

**URL:** <https://forums.swift.org/t/type-erasing-in-swift-anyview-behind-the-scenes/27952>\
**Category:** Using Swift\
**Tags:** generics, associatedtype\
**Created:** [August 16, 2019, 11:33am UTC](https://forums.swift.org/t/type-erasing-in-swift-anyview-behind-the-scenes/27952 "2019-08-16T11:33:53Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![filip-sakel](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/filip-sakel/32/8697_2.png) [@filip-sakel](https://forums.swift.org/u/filip-sakel)\
**Post date:** [July 15, 2021, 12:29pm UTC](https://forums.swift.org/t/type-erasing-in-swift-anyview-behind-the-scenes/27952/9 "2021-07-15T12:29:31Z")

</div>

Technically, this is type-erasing and is akin to the standard library’s implementation of `AnyCollection`. However, it’s not that useful, since — at least in the case of SwiftUI — `AnyView` must not have generic type parameters to be used in the [implementation of `TupleView`](https://forums.swift.org/t/swiftui-viewbuilder-result-is-a-tupleview-how-is-apple-using-it-and-able-to-avoid-turning-things-into-anyview/28181/13). Of course, I imagine that this kind of type erasing could be useful for not exposing internal types to the public API.

---

_[View the full topic](https://forums.swift.org/t/type-erasing-in-swift-anyview-behind-the-scenes/27952)._
