@@ -44,6 +44,8 @@ public func find<
44
44
}
45
45
46
46
/// Returns the lesser of `x` and `y`.
47
+ ///
48
+ /// If `x == y`, returns `x`.
47
49
@warn_unused_result
48
50
public func min< T : Comparable > ( x: T , _ y: T ) -> T {
49
51
// In case `x == y` we pick `x`.
@@ -54,6 +56,8 @@ public func min<T : Comparable>(x: T, _ y: T) -> T {
54
56
}
55
57
56
58
/// Returns the least argument passed.
59
+ ///
60
+ /// If there are multiple equal least arguments, returns the first one.
57
61
@warn_unused_result
58
62
public func min< T : Comparable > ( x: T , _ y: T , _ z: T , _ rest: T ... ) -> T {
59
63
var minValue = min ( min ( x, y) , z)
@@ -65,13 +69,17 @@ public func min<T : Comparable>(x: T, _ y: T, _ z: T, _ rest: T...) -> T {
65
69
}
66
70
67
71
/// Returns the greater of `x` and `y`.
72
+ ///
73
+ /// If `x == y`, returns `y`.
68
74
@warn_unused_result
69
75
public func max< T : Comparable > ( x: T , _ y: T ) -> T {
70
76
// In case `x == y`, we pick `y`. See min(_:_:).
71
77
return y >= x ? y : x
72
78
}
73
79
74
80
/// Returns the greatest argument passed.
81
+ ///
82
+ /// If there are multiple equal greatest arguments, returns the last one.
75
83
@warn_unused_result
76
84
public func max< T : Comparable > ( x: T , _ y: T , _ z: T , _ rest: T ... ) -> T {
77
85
var maxValue = max ( max ( x, y) , z)
0 commit comments