Folks are jealous of other programming languages having this kind of pattern matching abilities :
fun compareNumbers(
a: Int,
b: Int
) = when {
a > b -> "A is greater than B"
b > a -> "B is greater than A"
else -> "A and B are equal"
}
But, so do we :
const compareNumbers
This is probably just my general dislike of chained ternary operators, but why not just write this out the “long” way to make intention clearer?
Yeh, I’d just do early return.
It’s not much more typing, and I find it easier to read and navigate specific conditional paths.
Some built in pattern matching would be cool (like the when keyword), but I’m not going to force it into my code
Probably just my general dislike of verbosity 😅