zachtib
09/12/2019, 7:41 PMPablo Schmid
09/12/2019, 7:42 PMzachtib
09/12/2019, 7:42 PM.exhaustive
val extensionPablo Schmid
09/12/2019, 7:44 PMzachtib
09/12/2019, 7:45 PMandym
09/12/2019, 7:48 PMwhen
is not exhaustive when it’s not used as an expression. Ran into that some months ago.
I was under the impression it was done for safety, and that gave me warm-fuzzies. Looks like it was only done because the compiler needs a value for the expression.
I believe the equivalent in Swift is always exhaustive.Pablo Schmid
09/12/2019, 7:48 PMzachtib
09/12/2019, 7:49 PMif
statement if you’re only looking for a single typePablo Schmid
09/12/2019, 7:50 PMzachtib
09/12/2019, 7:51 PM.exhaustive
val from that article will let you force your when blocks to be exhaustive. Outside of that, I guess there are situations where you only want to handle a couple of potential cases, so the compiler doesn’t force you ALWAYS to handle them allPablo Schmid
09/12/2019, 9:00 PM