Files
kotlin-fork/compiler/testData/codegen/box/operatorConventions/compareTo/extensionArray.kt
T
Alexander Udalov 128c938965 Make Array.size() a function instead of a property
Also add a deprecated extension property to help migration. This is done to
unify getting size of arrays and collections
2014-11-17 15:02:38 +03:00

17 lines
445 B
Kotlin

fun checkLess(x: Array<Int>, y: Array<Int>) = when {
x >= y -> "Fail $x >= $y"
!(x < y) -> "Fail !($x < $y)"
!(x <= y) -> "Fail !($x <= $y)"
x > y -> "Fail $x > $y"
x.compareTo(y) >= 0 -> "Fail $x.compareTo($y) >= 0"
else -> "OK"
}
fun Array<Int>.compareTo(other: Array<Int>) = size() - other.size()
fun box(): String {
val a = Array<Int>(0, {0})
val b = Array<Int>(1, {0})
return checkLess(a, b)
}