Cache argument of when expression (should be evaluated only once).
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package foo
|
||||
|
||||
fun box() : Boolean {
|
||||
var a = 0
|
||||
var i = 0
|
||||
when(i++) {
|
||||
-100 -> a++
|
||||
100 -> a++
|
||||
else -> a++
|
||||
}
|
||||
return (a == 1) && (i == 1)
|
||||
}
|
||||
Reference in New Issue
Block a user