---
title: "prefix(_:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/anycollection/prefix(_:)"
---

# prefix(_:)

## Declaration

```swift
func prefix(_ maxLength: Int = 1) -> AnyCollection<Element>
```
