I recently discovered this nice syntax for a function that only returns a value based on the input:
fun getItem(value: Int): String = when (getPosition(value)) {
0 -> "Zero"
1 -> "One"
2 -> "Two"
else -> "Other"
}
Is it also possible to use ranges or <> operators?
I've tried doing things like:
>0 -> "Positive"
Which is not accepted, and
0-10 -> "Postively small"
is (naturally) seen as "0 minus 10" I think.