Rename copyToArray() to toTypedArray().
This commit is contained in:
@@ -77,9 +77,12 @@ public fun ByteArray.toString(charset: String): String = String(this, charset)
|
||||
public fun ByteArray.toString(charset: Charset): String = String(this, charset)
|
||||
|
||||
/**
|
||||
* Returns an array containing the elements of this collection.
|
||||
* 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.
|
||||
*/
|
||||
[Intrinsic("kotlin.collections.copyToArray")] public fun <reified T> Collection<T>.copyToArray(): Array<T> =
|
||||
[Intrinsic("kotlin.collections.copyToArray")] public fun <reified T> Collection<T>.toTypedArray(): Array<T> =
|
||||
throw UnsupportedOperationException()
|
||||
|
||||
/** Returns the array if it's not null, or an empty array otherwise. */
|
||||
|
||||
@@ -36,3 +36,6 @@ inline public fun byteArray(vararg content : Byte) : ByteArray = byteAr
|
||||
suppress("NOTHING_TO_INLINE")
|
||||
deprecated("Use booleanArrayOf() instead.")
|
||||
inline public fun booleanArray(vararg content : Boolean) : BooleanArray = booleanArrayOf(*content)
|
||||
|
||||
deprecated("Use toTypedArray() instead.")
|
||||
inline public fun <reified T> Collection<T>.copyToArray(): Array<T> = toTypedArray()
|
||||
@@ -94,7 +94,7 @@ public fun String.split(regex: Pattern, limit: Int = 0): List<String> = regex.sp
|
||||
* Splits this string around matches of the given regular expression.
|
||||
*/
|
||||
deprecated("Convert an argument to regex with toRegex or use splitBy instead.")
|
||||
public fun String.split(regex: String): Array<String> = split(regex.toRegex()).copyToArray()
|
||||
public fun String.split(regex: String): Array<String> = split(regex.toRegex()).toTypedArray()
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -91,7 +91,7 @@ class CollectionJVMTest {
|
||||
|
||||
test fun toArray() {
|
||||
val data = listOf("foo", "bar")
|
||||
val arr = data.copyToArray()
|
||||
val arr = data.toTypedArray()
|
||||
println("Got array ${arr}")
|
||||
assertEquals(2, arr.size())
|
||||
todo {
|
||||
|
||||
@@ -286,7 +286,7 @@ class CollectionTest {
|
||||
|
||||
test fun copyToArray() {
|
||||
val data = listOf("foo", "bar")
|
||||
val arr = data.copyToArray()
|
||||
val arr = data.toTypedArray()
|
||||
println("Got array ${arr}")
|
||||
assertEquals(2, arr.size())
|
||||
todo {
|
||||
|
||||
@@ -31,7 +31,7 @@ class JavautilCollectionsTest {
|
||||
}
|
||||
|
||||
test fun collectionToArray() {
|
||||
val array = TEST_LIST.copyToArray()
|
||||
val array = TEST_LIST.toTypedArray()
|
||||
assertEquals(array.toList(), TEST_LIST)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user