mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-09 15:53:37 +00:00
17 lines
367 B
Kotlin
Vendored
17 lines
367 B
Kotlin
Vendored
// KJS_WITH_FULL_RUNTIME
|
|
// WITH_RUNTIME
|
|
|
|
val arr = arrayOf(10, 20, 30, 40)
|
|
|
|
fun <T : Number> foo(xs: Array<T>): String {
|
|
val s = StringBuilder()
|
|
for ((index, x) in xs.withIndex()) {
|
|
s.append("$index:$x;")
|
|
}
|
|
return s.toString()
|
|
}
|
|
|
|
fun box(): String {
|
|
val ss = foo(arr)
|
|
return if (ss == "0:10;1:20;2:30;3:40;") "OK" else "fail: '$ss'"
|
|
} |