coerceAtLeast
Ensures that this value is not less than the specified minimumValue.
Since Kotlin
1.0Return
this value if it's greater than or equal to the minimumValue or the minimumValue otherwise.
Samples
import java.time.DayOfWeek
import kotlin.test.assertFailsWith
fun main() {
//sampleStart
println(DayOfWeek.WEDNESDAY.coerceAtLeast(DayOfWeek.MONDAY)) // WEDNESDAY
println(DayOfWeek.WEDNESDAY.coerceAtLeast(DayOfWeek.FRIDAY)) // FRIDAY
//sampleEnd
}
Ensures that this value is not less than the specified minimumValue.
Since Kotlin
1.0Return
this value if it's greater than or equal to the minimumValue or the minimumValue otherwise.
Samples
import java.time.DayOfWeek
import kotlin.test.assertFailsWith
fun main() {
//sampleStart
println(10.coerceAtLeast(5)) // 10
println(10.coerceAtLeast(20)) // 20
//sampleEnd
}