groostav
08/17/2023, 6:37 PMgroostav
08/17/2023, 6:38 PMA > B, and A < B and A == B cover all possible values, and thus you wouldnt need an else clause and the warning from intelliJ would be superfluousdmitriy.novozhilov
08/17/2023, 8:35 PMDominaezzz
08/17/2023, 9:10 PMhfhbd
08/17/2023, 9:59 PMAlejandro Serrano Mena
08/18/2023, 8:08 AMgroostav
08/18/2023, 5:10 PMwhen statements to reduce the scope.
given that we've taken the step of making all when uses into expressions, removing then when statement, I think a logical step is to start pushing users away from else clauses in favor of better (SAT) proovably coverage statements.
In an ideal world, where size operators return a UInt, and you have such a sat solver, one could write something like
when(val it: UInt = list.size) {
0 -> {}
1, 2 -> {}
in 3 .. 4 -> {}
in 4 .. Int.MAX_VLAUE -> {}
}
This would give you a kind of pseudo sealed-class out of ints, which would be helpful if you're adding and changing sentinel values (ie, SPECIAL_SIZE -> ..
that said, if SpecialSize is computed or even soft-coded, as it is very likely to be, our solvers life becomes difficult.
So thinking aout it, it seems like a lot of work and a pretty huge chang efor not a lot of gain. 😕