Add SinceKotlin to new coerceIn method.
This commit is contained in:
@@ -868,6 +868,7 @@ public fun Double.coerceIn(minimumValue: Double, maximumValue: Double): Double {
|
||||
*
|
||||
* @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`.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public fun <T: Comparable<T>> T.coerceIn(range: ClosedFloatingPointRange<T>): T {
|
||||
if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.")
|
||||
return when {
|
||||
|
||||
@@ -620,6 +620,7 @@ public header fun Double.coerceIn(minimumValue: Double, maximumValue: Double): D
|
||||
*
|
||||
* @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`.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public header fun <T: Comparable<T>> T.coerceIn(range: ClosedFloatingPointRange<T>): T
|
||||
|
||||
/**
|
||||
|
||||
@@ -869,6 +869,7 @@ public fun Double.coerceIn(minimumValue: Double, maximumValue: Double): Double {
|
||||
*
|
||||
* @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`.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public fun <T: Comparable<T>> T.coerceIn(range: ClosedFloatingPointRange<T>): T {
|
||||
if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.")
|
||||
return when {
|
||||
|
||||
@@ -90,6 +90,7 @@ fun comparables(): List<GenericFunction> {
|
||||
templates add f("coerceIn(range: ClosedFloatingPointRange<T>)") {
|
||||
sourceFile(SourceFile.Ranges)
|
||||
only(Generic)
|
||||
since("1.1")
|
||||
returns("SELF")
|
||||
typeParam("T: Comparable<T>")
|
||||
doc {
|
||||
|
||||
Reference in New Issue
Block a user