---
title: AnySequence
framework: swift
role: symbol
role_heading: Structure
path: swift/anysequence
---

# AnySequence

A type-erased sequence.

## Declaration

```swift
@frozen struct AnySequence<Element>
```

## Overview

Overview An instance of AnySequence forwards its operations to an underlying base sequence having the same Element type, hiding the specifics of the underlying sequence.

## Topics

### Initializers

- [init(_:)](swift/anysequence/init(_:)-25934.md)
- [init(_:)](swift/anysequence/init(_:)-307a9.md)

### Instance Methods

- [drop(while:)](swift/anysequence/drop(while:).md)
- [dropFirst(_:)](swift/anysequence/dropfirst(_:).md)
- [dropLast(_:)](swift/anysequence/droplast(_:).md)
- [filter(_:)](swift/anysequence/filter(_:).md)
- [forEach(_:)](swift/anysequence/foreach(_:).md)
- [map(_:)](swift/anysequence/map(_:).md)
- [prefix(_:)](swift/anysequence/prefix(_:).md)
- [prefix(while:)](swift/anysequence/prefix(while:).md)
- [suffix(_:)](swift/anysequence/suffix(_:).md)

### Default Implementations

- [Sequence Implementations](swift/anysequence/sequence-implementations.md)

## Relationships

### Conforms To

- [Copyable](swift/copyable.md)
- [Escapable](swift/escapable.md)
- [Sequence](swift/sequence.md)

## See Also

### Type-Erasing Wrappers

- [AnyCollection](swift/anycollection.md)
- [AnyBidirectionalCollection](swift/anybidirectionalcollection.md)
- [AnyRandomAccessCollection](swift/anyrandomaccesscollection.md)
- [AnyIterator](swift/anyiterator.md)
- [AnyIndex](swift/anyindex.md)
- [AnyHashable](swift/anyhashable.md)
