toTypedArray
fun
ByteArray
.
toTypedArray
(
)
:
Array
<
Byte
>
(Common source) (JVM source) (JS source) (Native source)
fun
ShortArray
.
toTypedArray
(
)
:
Array
<
Short
>
(Common source) (JVM source) (JS source) (Native source)
fun
IntArray
.
toTypedArray
(
)
:
Array
<
Int
>
(Common source) (JVM source) (JS source) (Native source)
fun
LongArray
.
toTypedArray
(
)
:
Array
<
Long
>
(Common source) (JVM source) (JS source) (Native source)
fun
FloatArray
.
toTypedArray
(
)
:
Array
<
Float
>
(Common source) (JVM source) (JS source) (Native source)
fun
DoubleArray
.
toTypedArray
(
)
:
Array
<
Double
>
(Common source) (JVM source) (JS source) (Native source)
fun
BooleanArray
.
toTypedArray
(
)
:
Array
<
Boolean
>
(Common source) (JVM source) (JS source) (Native source)
fun
CharArray
.
toTypedArray
(
)
:
Array
<
Char
>
(Common source) (JVM source) (JS source) (Native source)
Returns a typed object array containing all of the elements of this primitive array.
fun
<
reified
T
>
Collection
<
T
>
.
toTypedArray
(
)
:
Array
<
T
>
(Common source) (JVM source) (Native source)
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.
import kotlin.test.*
fun main(args: Array<String>) {
//sampleStart
val collection = listOf(1, 2, 3)
val array = collection.toTypedArray()
println(array.contentToString()) // [1, 2, 3]
//sampleEnd
}