<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/AsyncThrowingDropWhileSequence/max()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:Sci12_ConcurrencySL7ElementRpzrlE3maxACSgyYaKF::SYNTHESIZED::s:12_Concurrency30AsyncThrowingDropWhileSequenceV"
  },
  "title" : "max()"
}
-->

# max()

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

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

## Return Value

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

## 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"
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)