e4ecc13e13
In Kotlin 1.3+, assignment to the for-in-array loop range variable in the loop body doesn't affect loop execution (as if it was a loop on an array iterator, or some other container). #KT-21354 In Progress #KT-21321 In Progress
13 lines
266 B
Kotlin
Vendored
13 lines
266 B
Kotlin
Vendored
// WITH_RUNTIME
|
|
// LANGUAGE_VERSION: 1.2
|
|
// IGNORE_BACKEND: JS
|
|
|
|
fun box(): String {
|
|
var xs = intArrayOf(1, 2, 3)
|
|
var sum = 0
|
|
for (x in xs) {
|
|
sum = sum * 10 + x
|
|
xs = intArrayOf(4, 5)
|
|
}
|
|
return if (sum == 15) "OK" else "Fail: $sum"
|
|
} |