---
title: max()
framework: swift
role: symbol
role_heading: Instance Method
path: swift/throwingtaskgroup/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

### Accessing an Asynchronous Sequence of Results

- [makeAsyncIterator()](swift/throwingtaskgroup/makeasynciterator().md)
- [allSatisfy(_:)](swift/throwingtaskgroup/allsatisfy(_:).md)
- [compactMap(_:)](swift/throwingtaskgroup/compactmap(_:)-944nh.md)
- [compactMap(_:)](swift/throwingtaskgroup/compactmap(_:)-7mgi5.md)
- [contains(_:)](swift/throwingtaskgroup/contains(_:).md)
- [contains(where:)](swift/throwingtaskgroup/contains(where:).md)
- [drop(while:)](swift/throwingtaskgroup/drop(while:).md)
- [dropFirst(_:)](swift/throwingtaskgroup/dropfirst(_:).md)
- [filter(_:)](swift/throwingtaskgroup/filter(_:).md)
- [first(where:)](swift/throwingtaskgroup/first(where:).md)
- [map(_:)](swift/throwingtaskgroup/map(_:)-58nrv.md)
- [map(_:)](swift/throwingtaskgroup/map(_:)-4a4ju.md)
- [max(by:)](swift/throwingtaskgroup/max(by:).md)
- [min()](swift/throwingtaskgroup/min().md)
- [min(by:)](swift/throwingtaskgroup/min(by:).md)
