toTypedArray

fun UIntArray.toTypedArray(): Array<UInt>
fun ULongArray.toTypedArray(): Array<ULong>
fun UByteArray.toTypedArray(): Array<UByte>

Returns a typed object array containing all of the elements of this primitive array.

Since Kotlin

1.3

expect fun ByteArray.toTypedArray(): Array<Byte>
expect fun ShortArray.toTypedArray(): Array<Short>
expect fun IntArray.toTypedArray(): Array<Int>
expect fun LongArray.toTypedArray(): Array<Long>
expect fun FloatArray.toTypedArray(): Array<Float>
expect fun DoubleArray.toTypedArray(): Array<Double>
expect fun BooleanArray.toTypedArray(): Array<Boolean>
expect fun CharArray.toTypedArray(): Array<Char>

Returns a typed object array containing all of the elements of this primitive array.


expect inline fun <T> Collection<T>.toTypedArray(): Array<T>
actual fun ByteArray.toTypedArray(): Array<Byte>
actual fun ShortArray.toTypedArray(): Array<Short>
actual fun IntArray.toTypedArray(): Array<Int>
actual fun LongArray.toTypedArray(): Array<Long>
actual fun FloatArray.toTypedArray(): Array<Float>
actual fun DoubleArray.toTypedArray(): Array<Double>
actual fun BooleanArray.toTypedArray(): Array<Boolean>
actual fun CharArray.toTypedArray(): Array<Char>

Returns a typed object array containing all of the elements of this primitive array.


actual inline fun <T> Collection<T>.toTypedArray(): Array<T>

Returns a typed array containing all of the elements of this collection.

Allocates an array of runtime type T having its size equal to the size of this collection and populates the array with the elements of this collection.

Samples

import samples.*
import kotlin.test.*
fun main() { 
   //sampleStart 
   val collection = listOf(1, 2, 3)
val array = collection.toTypedArray()
assertPrints(array.contentToString(), "[1, 2, 3]") 
   //sampleEnd
}
actual fun ByteArray.toTypedArray(): Array<Byte>
actual fun ShortArray.toTypedArray(): Array<Short>
actual fun IntArray.toTypedArray(): Array<Int>
actual fun LongArray.toTypedArray(): Array<Long>
actual fun FloatArray.toTypedArray(): Array<Float>
actual fun DoubleArray.toTypedArray(): Array<Double>
actual fun BooleanArray.toTypedArray(): Array<Boolean>
actual fun CharArray.toTypedArray(): Array<Char>

Returns a typed object array containing all of the elements of this primitive array.


actual inline fun <T> Collection<T>.toTypedArray(): Array<T>
actual fun ByteArray.toTypedArray(): Array<Byte>
actual fun ShortArray.toTypedArray(): Array<Short>
actual fun IntArray.toTypedArray(): Array<Int>
actual fun LongArray.toTypedArray(): Array<Long>
actual fun FloatArray.toTypedArray(): Array<Float>
actual fun DoubleArray.toTypedArray(): Array<Double>
actual fun BooleanArray.toTypedArray(): Array<Boolean>
actual fun CharArray.toTypedArray(): Array<Char>

Returns a typed object array containing all of the elements of this primitive array.


actual inline fun <T> Collection<T>.toTypedArray(): Array<T>

Returns a typed array containing all of the elements of this collection.

Allocates an array of runtime type T having its size equal to the size of this collection and populates the array with the elements of this collection.