Add samples for coerceIn

#KT-20357
This commit is contained in:
shiraji
2018-01-10 11:45:12 +09:00
committed by Ilya Gorbunov
parent 4559da9848
commit 17573a3c21
5 changed files with 22 additions and 0 deletions
@@ -641,6 +641,7 @@ public expect fun <T: Comparable<T>> T.coerceIn(range: ClosedFloatingPointRange<
* Ensures that this value lies in the specified [range].
*
* @return this value if it's in the [range], or `range.start` if this value is less than `range.start`, or `range.endInclusive` if this value is greater than `range.endInclusive`.
* @sample samples.comparisons.ComparableOps.coerceIn
*/
public expect fun <T: Comparable<T>> T.coerceIn(range: ClosedRange<T>): T
@@ -648,6 +649,7 @@ public expect fun <T: Comparable<T>> T.coerceIn(range: ClosedRange<T>): T
* Ensures that this value lies in the specified [range].
*
* @return this value if it's in the [range], or `range.start` if this value is less than `range.start`, or `range.endInclusive` if this value is greater than `range.endInclusive`.
* @sample samples.comparisons.ComparableOps.coerceIn
*/
public expect fun Int.coerceIn(range: ClosedRange<Int>): Int
@@ -655,6 +657,7 @@ public expect fun Int.coerceIn(range: ClosedRange<Int>): Int
* Ensures that this value lies in the specified [range].
*
* @return this value if it's in the [range], or `range.start` if this value is less than `range.start`, or `range.endInclusive` if this value is greater than `range.endInclusive`.
* @sample samples.comparisons.ComparableOps.coerceIn
*/
public expect fun Long.coerceIn(range: ClosedRange<Long>): Long