max

func max<T where T : Comparable>(_: T, _: T)

Returns the greater of two comparable values.

Parameters: x: A value to compare. y: Another value to compare. Returns: The greater of x and y. If x is equal to y, returns y.

Declaration

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

Returns the greatest argument passed.

Parameters: x: A value to compare. y: Another value to compare. z: A third value to compare. rest: Zero or more additional values. Returns: The greatest of all the arguments. If there are multiple equal greatest arguments, the result is the last one.

Declaration

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