https://kotlinlang.org logo
#compiler
Title
# compiler
s

Sam Stone

10/06/2023, 4:01 AM
And, if there are consecutive identical branches, it can't optimize them:
Copy code
when(i) {
    1->false
    2->true
    3->true
    4->true
    5,6,7 -> false
...
} 
//equivalent to
if(var1 == 1) false else if(var1 == 2) true else if (var1 == 3) true else if (var4 == 4) true else if(var1 == 5 || var1 == 6 || var1 == 7) false