Files
kotlin-fork/compiler/testData/codegen/box/vararg/kt581.kt
T
Alexander Udalov 93696ff9bd Make Array.indices extension property, move to stdlib
This is not something that needs to be intrinsified. Note that compiler
optimizations are still possible and the fact whether 'indices' is a member or
an extension is irrelevant to the optimizer
2014-11-17 15:20:44 +03:00

20 lines
505 B
Kotlin

package whats.the.difference
import java.util.HashSet
fun iarray(vararg a : Int) = a // BUG
val IntArray.indices: IntRange get() = IntRange(0, lastIndex())
fun IntArray.lastIndex() = size() - 1
fun box() : String {
val vals = iarray(789, 678, 567, 456, 345, 234, 123, 12)
val diffs = HashSet<Int>()
for (i in vals.indices)
for (j in i..vals.lastIndex())
diffs.add(vals[i] - vals[j])
val size = diffs.size()
if (size != 8) return "Fail $size"
return "OK"
}