
kotlin.collections.Arrays.kt Maven / Gradle / Ivy
package kotlin
/**
* Returns an array with the specified [size], where each element is calculated by calling the specified
* [init] function. The `init` function returns an array element given its index.
*/
public inline fun Array(size: Int, init: (Int) -> T): Array {
val result = arrayOfNulls(size)
for (i in 0..size - 1) {
result[i] = init(i)
}
return result as Array
}
/**
* Returns an empty array of the specified type [T].
*/
public inline fun emptyArray(): Array = arrayOfNulls(0) as Array
© 2015 - 2025 Weber Informatics LLC | Privacy Policy