---
title: "max(_:_:_:_:)"
framework: swift
role: symbol
role_heading: Function
path: "swift/max(_:_:_:_:)"
---

# max(_:_:_:_:)

Returns the greatest argument passed.

## Declaration

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

## Parameters

- `x`: A value to compare.
- `y`: Another value to compare.
- `z`: A third value to compare.
- `rest`: Zero or more additional values.

## Return Value

Return Value The greatest of all the arguments. If there are multiple equal greatest arguments, the result is the last one.

## See Also

### Choosing the Smallest and Largest Value

- [min(_:_:)](swift/min(_:_:).md)
- [min(_:_:_:_:)](swift/min(_:_:_:_:).md)
- [max(_:_:)](swift/max(_:_:).md)
