Skip to content

Commit a61839d

Browse files
[stdlib] Add ordering guarantee to min() and max() docs
1 parent fe478b7 commit a61839d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

stdlib/public/core/Algorithm.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public func find<
4444
}
4545

4646
/// Returns the lesser of `x` and `y`.
47+
///
48+
/// If `x == y`, returns `x`.
4749
@warn_unused_result
4850
public func min<T : Comparable>(x: T, _ y: T) -> T {
4951
// In case `x == y` we pick `x`.
@@ -54,6 +56,8 @@ public func min<T : Comparable>(x: T, _ y: T) -> T {
5456
}
5557

5658
/// Returns the least argument passed.
59+
///
60+
/// If there are multiple equal least arguments, returns the first one.
5761
@warn_unused_result
5862
public func min<T : Comparable>(x: T, _ y: T, _ z: T, _ rest: T...) -> T {
5963
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 {
6569
}
6670

6771
/// Returns the greater of `x` and `y`.
72+
///
73+
/// If `x == y`, returns `y`.
6874
@warn_unused_result
6975
public func max<T : Comparable>(x: T, _ y: T) -> T {
7076
// In case `x == y`, we pick `y`. See min(_:_:).
7177
return y >= x ? y : x
7278
}
7379

7480
/// Returns the greatest argument passed.
81+
///
82+
/// If there are multiple equal greatest arguments, returns the last one.
7583
@warn_unused_result
7684
public func max<T : Comparable>(x: T, _ y: T, _ z: T, _ rest: T...) -> T {
7785
var maxValue = max(max(x, y), z)

0 commit comments

Comments
 (0)