Supported creating varargs of reified type parameter

This commit is contained in:
Denis Zharkov
2014-11-04 11:38:28 +04:00
committed by Andrey Breslav
parent 29b4ba9b3d
commit a8ca39754c
6 changed files with 114 additions and 17 deletions
@@ -0,0 +1,15 @@
import kotlin.test.assertEquals
inline fun <reified T> copy(c: Collection<T>): Array<T> {
return c.copyToArray()
}
fun box(): String {
val a: Array<String> = copy(listOf("a", "b", "c"))
assertEquals("abc", a.join(""))
val b: Array<Int> = copy(listOf(1,2,3))
assertEquals("123", b.map { it.toString() }.join(""))
return "OK"
}