looks like from the docs:
"If `when` is used as an expression, the `else` branch is mandatory, unless the compiler can prove that all possible cases are covered with branch conditions."
So it is an error, I assume?
looks like from the docs:
"If `when` is used as an expression, the `else` branch is mandatory, unless the compiler can prove that all possible cases are covered with branch conditions."
So it is an error, I assume?
> What about pattern matching? This is where the word “sealed” above comes in handy; we can do an exhaustive pattern match without an else/otherwise branch
from https://medium.com/@octskyward/kotlin-fp-3bf63a17d64a#.8dbwa...
You can basically consider 'when'-expressions to be syntax sugar over Java's if-else or ternary operator (?:) chains.
So there are no non-exhaustive pattern matches, is what you are saying? i.e. they all must be exhaustive. Except for your enum example
More info in the official reference: https://kotlinlang.org/docs/reference/control-flow.html#when...