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:
Denis Zharkov
2014-12-11 10:22:00 +03:00
committed by Alexander Udalov
parent 654411a0b0
commit d345ba05dd
4 changed files with 12 additions and 7 deletions
@@ -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