natpryce
05/17/2017, 8:55 AMwhen (fruit) {
is Apple -> printApple(fruit)
is Banana -> printBanana(fruit)
}
But if you add a non-null assertion at the end, it will be treated as an expression, and then the compiler will check for exhaustiveness, so the code below will not compile, as one would wish.
when (fruit) {
is Apple -> printApple(fruit)
is Banana -> printBanana(fruit)
}!!
But IntelliJ marks the !! with an unused code warning.