I'm a bit annoyed with the line of code below. I'm wondering if there are any build-in function in the Kotlin SDK that could do the same in a more elegant way.
val result = if (value > 0) value else 0
I'm a bit annoyed with the line of code below. I'm wondering if there are any build-in function in the Kotlin SDK that could do the same in a more elegant way.
val result = if (value > 0) value else 0
val result = value.coerceAtLeast(0)
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.ranges/coerce-at-least.html