```fun <C : Comparable<C>> C.coerceAtM...
# stdlib
h
Copy code
fun <C : Comparable<C>> C.coerceAtMost(maxValue: C) = if (this > maxValue) maxValue else this
fun <C : Comparable<C>> C.coerceAtLeast(minValue: C) = if (this < minValue) minValue else this
fun <C : Comparable<C>> C.coerceIn(minValue: C, maxValue: C) = coerceAtLeast(minValue).coerceAtMost(maxValue)
Also
Copy code
fun <C : Comparable<C>> min(vararg elements: C): C
fun <C : Comparable<C>> max(vararg elements: C): C
I'm a bit surprised these methods aren't part of stdlib of any languages i know of. Is there a reason I haven't considered?
h
i don't understand how i somehow missed it when i'm running 1.4-M3 and it's been in since 1.3 maybe i wasn't using comparable classes on accident... idk