Allow _ in exhaustive when

I know why you want this. Using when as an expression is the only way (right now) to ensure that the compiler checks that it is exhaustive.
That being said I don’t like your suggestion to handle it as it feels like a hack and not like a feature. Instead I would take a look at this topic. There is a discussion about the same problem. I like @fvasco’s suggestion

when(x) {
    is A -> doA()
    is B -> doB()
    !else
}
2 Likes