Added inline function "Array" into stdlib
It has the same signature and semantics as Array constructor had Also made Array constructor private and accepting no arguments
This commit is contained in:
committed by
Alexander Udalov
parent
654411a0b0
commit
d345ba05dd
@@ -1,5 +1,15 @@
|
||||
package kotlin
|
||||
|
||||
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>
|
||||
}
|
||||
|
||||
public val BooleanArray.lastIndex: Int
|
||||
get() = this.size - 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user