mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-10 00:21:35 +00:00
The condition of a do-while loop can use variables declared in the loop (variables can only be declared inside a block). Previously this behaviour caused crash because after the block was generated, all variables declared inside that block were gone from myFrameMap #KT-3280 Fixed
16 lines
307 B
Kotlin
16 lines
307 B
Kotlin
fun box(): String {
|
|
var x = 0
|
|
do x++ while (x < 5)
|
|
if (x != 5) return "Fail 1 $x"
|
|
|
|
var y = 0
|
|
do { y++ } while (y < 5)
|
|
if (y != 5) return "Fail 2 $y"
|
|
|
|
var z = ""
|
|
do { z += z.length } while (z.length < 5)
|
|
if (z != "01234") return "Fail 3 $z"
|
|
|
|
return "OK"
|
|
}
|