mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-09 00:21:47 +00:00
There is a lot of changes about closures calculating and generating. 1. As classes can have more than one constructor each of them should have closure arguments. 2. Captured variables set is the same for all of them. 3. Within constructors bodies/delegating calls closure parameters should be accessed through method arguments because fields may be not initialized yet.
24 lines
365 B
Kotlin
Vendored
24 lines
365 B
Kotlin
Vendored
fun join(x: Array<out String>): String {
|
|
var result = ""
|
|
for (i in x) {
|
|
result += i
|
|
result += "#"
|
|
}
|
|
|
|
return result
|
|
}
|
|
|
|
class A {
|
|
val prop: String
|
|
constructor(vararg x: String) {
|
|
prop = join(x)
|
|
}
|
|
}
|
|
|
|
fun box(): String {
|
|
val a1 = WithVarargs.foo()
|
|
if (a1 != "1#2#3#") return "fail1: ${a1}"
|
|
|
|
return "OK"
|
|
}
|