Is there a clip/clamp for numbers in the stdlib (s...
# stdlib
h
Is there a clip/clamp for numbers in the stdlib (similar to https://stackoverflow.com/questions/4092528/how-to-clamp-an-integer-to-some-range)?
a
coerceIn
,
coerceAtLeast
and
coerceAtMost
should do the trick depending on your case: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.ranges/coerce-in.html
h
Thanks!