<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/max(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s3maxyxx_xtSLRzlF"
  },
  "title" : "max(_:_:)"
}
-->

# max(_:_:)

Returns the greater of two comparable values.

```
func max<T>(_ x: T, _ y: T) -> T where T : Comparable
```

## Parameters

`x`

A value to compare.

`y`

Another value to compare.

## Return Value

The greater of `x` and `y`. If `x` is equal to `y`, returns `y`.

---

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)