min()
1、**返回两个可比值中较小的一个。**
/// 返回两个可比值中较小的一个。
/// Returns the lesser of two comparable values.
///
/// - Parameters:
/// - x: A value to compare.
/// - y: Another value to compare.
/// - Returns: The lesser of `x` and `y`. If `x` is equal to `y`, returns `x`.
@inlinable public func min<T>(_ x: T, _ y: T) -> T where T : Comparable
如:min(5, 8)
等于 5
2、**返回多个可比值中最小的一个。**
/// 返回多个可比值中最小的一个。
/// Returns the least 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 least of all the arguments. If there are multiple equal
/// least arguments, the result is the first one.
@inlinable public func min<T>(_ x: T, _ y: T, _ z: T, _ rest: T...) -> T where T : Comparable
如:min(5, 8,9)
等于 5
max()
1、**返回两个可比值中较大的一个。**
/// 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`.
@inlinable public func min<T>(_ x: T, _ y: T) -> T where T : Comparable
如:max(5, 8)
等于 8
2、**返回多个可比值中最大的一个。。**
/// 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.
@inlinable public func min<T>(_ x: T, _ y: T, _ z: T, _ rest: T...) -> T where T : Comparable
如:max(5, 8,9)
等于 9
网友评论