---
title: max()
framework: swift
role: symbol
role_heading: Instance Method
path: swift/asyncthrowingstream/max()
---

# max()

Returns the maximum element in an asynchronous sequence of comparable elements.

## Declaration

```swift
@warn_unqualified_access func max() async rethrows -> Self.Element?
```

## Return Value

Return Value The sequence’s maximum element. If the sequence has no elements, returns nil.

## Discussion

Discussion In this example, an asynchronous sequence called Counter produces Int values from 1 to 10. The max() method returns the max value of the sequence. let max = await Counter(howHigh: 10)     .max() print(max ?? "none") // Prints "10"

## See Also

### Finding Elements

- [contains(_:)](swift/asyncthrowingstream/contains(_:).md)
- [contains(where:)](swift/asyncthrowingstream/contains(where:).md)
- [allSatisfy(_:)](swift/asyncthrowingstream/allsatisfy(_:).md)
- [first(where:)](swift/asyncthrowingstream/first(where:).md)
- [min()](swift/asyncthrowingstream/min().md)
- [min(by:)](swift/asyncthrowingstream/min(by:).md)
- [max(by:)](swift/asyncthrowingstream/max(by:).md)
