add clamp

This commit is contained in:
InsanusMokrassar 2020-12-07 22:39:23 +06:00
parent 527f7bbafe
commit 90c0817b6d
2 changed files with 13 additions and 0 deletions

View File

@ -2,6 +2,9 @@
## 0.4.11
* `Common`
* Add `clamp` function
## 0.4.10
* `Versions`:

View File

@ -0,0 +1,10 @@
package dev.inmo.micro_utils.common
@Suppress("NOTHING_TO_INLINE")
inline fun <T : Comparable<T>> T.clamp(min: T, max: T): T {
return when {
this < min -> min
this > max -> max
else -> this
}
}