Supported creating varargs of reified type parameter
This commit is contained in:
committed by
Andrey Breslav
parent
29b4ba9b3d
commit
a8ca39754c
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user