News for hackers. Stuff that matters.
Re:The Kotlin Language: 1.0 Beta Is Here by udalov on Monday November 02, 2015 @03:17PM (#10494867)
It's an error only when the 'when'-expression is used as a value, like assigned to a property, passed as an argument or returned from a function. Otherwise it's not an error. There's also a warning for matching enum values over an incomplete set of enum entries, but otherwise non-exhaustive 'when'-expression is green code.

You can basically consider 'when'-expressions to be syntax sugar over Java's if-else or ternary operator (?:) chains.

Re:The Kotlin Language: 1.0 Beta Is Here by platz on Monday November 02, 2015 @03:31PM (#10494971)
> non-exhaustive pattern matches

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

Re:The Kotlin Language: 1.0 Beta Is Here by udalov on Monday November 02, 2015 @04:12PM (#10495282)
No, as I mentioned, only those 'when'-expressions, the result of which is used as a value, must be exhaustive. Those which are not, we call them 'when'-statements, correspond to an if-else chain in C-like languages and thus are not required to be exhaustive.

More info in the official reference: https://kotlinlang.org/docs/reference/control-flow.html#when...