diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/collections/Arrays.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/collections/Arrays.kt index 0672afcd9f2..87a5a886b4f 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/collections/Arrays.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/collections/Arrays.kt @@ -111,6 +111,7 @@ internal actual fun copyToArrayImpl(collection: Collection<*>, array: Array< * * 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. + * @sample samples.collections.Collections.Collections.collectionToTypedArray */ public actual inline fun Collection.toTypedArray(): Array { val result = arrayOfNulls(size) diff --git a/libraries/stdlib/js/src/kotlin/collections.kt b/libraries/stdlib/js/src/kotlin/collections.kt index 0a5a982a784..7e1dcff803e 100644 --- a/libraries/stdlib/js/src/kotlin/collections.kt +++ b/libraries/stdlib/js/src/kotlin/collections.kt @@ -12,6 +12,13 @@ import kotlin.random.Random @kotlin.internal.InlineOnly public actual inline fun Array?.orEmpty(): Array = this ?: emptyArray() +/** + * 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. + * @sample samples.collections.Collections.Collections.collectionToTypedArray + */ @kotlin.internal.InlineOnly public actual inline fun Collection.toTypedArray(): Array = copyToArray(this)