coerceAtLeast

fun <T : Comparable<T>> T.coerceAtLeast(minimumValue: T): T(source)

Ensures that this value is not less than the specified minimumValue.

Since Kotlin

1.0

Return

this value if it's greater than or equal to the minimumValue or the minimumValue otherwise.

Samples


fun Byte.coerceAtLeast(minimumValue: Byte): Byte(source)
fun Short.coerceAtLeast(minimumValue: Short): Short(source)
fun Int.coerceAtLeast(minimumValue: Int): Int(source)
fun Long.coerceAtLeast(minimumValue: Long): Long(source)
fun Float.coerceAtLeast(minimumValue: Float): Float(source)
fun Double.coerceAtLeast(minimumValue: Double): Double(source)

Ensures that this value is not less than the specified minimumValue.

Since Kotlin

1.0

Return

this value if it's greater than or equal to the minimumValue or the minimumValue otherwise.

Samples