mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-09 08:31:29 +00:00
14 lines
279 B
Kotlin
14 lines
279 B
Kotlin
import kotlin.InlineOption.*
|
|
|
|
inline fun<reified T> createArray(n: Int, inlineOptions(ONLY_LOCAL_RETURN) block: () -> T): Array<T> {
|
|
return Array<T>(n) { block() }
|
|
}
|
|
|
|
fun box(): String {
|
|
|
|
val x = createArray<Int>(5) { 3 }
|
|
|
|
assert(x.all { it == 3 })
|
|
return "OK"
|
|
}
|