Hello,
I feel I should know this, but why do I need the
else
in this
when
? and please, elaborate on the "type erasure" answer 😄
Copy code
sealed interface Test
class Test1: Test
class Test2: Test
fun <T: Test> T.call() = when (this) {
is Test1 -> Unit
is Test2 -> Unit
else -> throw IllegalArgumentException("why?")
}