Make Array<T>(size, init) a constructor of Array
It's not marked as inline, this is why 'crossinline' was added in jaggedArray.kt/jaggedDeep.kt. Will be fixed in the following commits
This commit is contained in:
@@ -2,18 +2,6 @@ package kotlin
|
||||
|
||||
import java.util.*
|
||||
|
||||
// TODO: @library("arrayFromFun")
|
||||
/**
|
||||
* 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 <reified T> Array(size: Int, init: (Int) -> T): Array<T> {
|
||||
val result = arrayOfNulls<T>(size)
|
||||
for (i in 0..size - 1)
|
||||
result[i] = init(i)
|
||||
return result as Array<T>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an empty array of the specified type [T].
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user