Just curious, what is the motivation for `kotlin.r...
# stdlib
c
Just curious, what is the motivation for
kotlin.ranges.coerceAtLeast
and
kotlin.ranges.coerceAtMost
, any reason these should be used in place of
maxOf
/
minOf
? It surprises me that their implementation is not just
Math.max
and
Math.min
, but maybe I’m missing something!
Ah, nevermind. Of course
Math
is on the JVM
e
the `.coerceAtLeast`/`.coerceAtMost`/`.coerceIn` are more expressive.
Copy code
it.coerceAtMost(MAX)
minOf(it, MAX)
the number of bugs I've run across where the author wrote `min(MIN)`/`max(MAX)` is too high…
c
I see that, and I agree. My surprise at first was the difference in implementation. But of course that is explained by one being JVM-based.