https://kotlinlang.org logo
k

Klitos Kyriacou

01/12/2023, 9:15 AM
On this page: https://kotlinlang.org/docs/sealed-classes.html#sealed-classes-and-when-expression It says: "If it's possible to verify that the statement covers all cases, you don't need to add an
else
clause to the statement. However, this works only if you use
when
as an expression (using the result) and not as a statement". Can you explain the last sentence in more detail? I don't see any difference in the need (or otherwise) to add an
else
clause depending on whether the
when
block is used as an expression or a statement. Is this left over from an earlier version of Kotlin?
✔️ 1
v

Victoria Petrakovich

01/12/2023, 12:24 PM
Hi!
Is this left over from an earlier version of Kotlin?
Yes, seems like this. I’ll fix this a bit later. Thank you!
3 Views