Cache argument of when expression (should be evaluated only once).

This commit is contained in:
Pavel V. Talanov
2012-07-19 16:20:06 +04:00
parent cd2c55aeca
commit 534bde52f1
3 changed files with 37 additions and 6 deletions
@@ -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)
}