Generic Function

max(_:_:)

Returns the greater of two comparable values.

Declaration

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.

See Also

Choosing the Smallest and Largest Value

func min<T>(T, T) -> T

Returns the lesser of two comparable values.

func min<T>(T, T, T, T...) -> T

Returns the least argument passed.

func max<T>(T, T, T, T...) -> T

Returns the greatest argument passed.