Files
kotlin-fork/js/js.translator/testData/operatorOverloading/cases/overloadPlusViaExtensionFunction.kt
T
2016-01-22 05:54:38 +03:00

21 lines
388 B
Kotlin
Vendored

package foo
import java.util.*
operator fun <T> ArrayList<T>.plus(other: Collection<T>): List<T> {
val c = ArrayList<T>()
c.addAll(this)
c.addAll(other)
return c
}
fun box(): Boolean {
var v1 = ArrayList<String>()
v1.add("foo")
val v2 = ArrayList<String>()
v2.add("bar")
val v = v1 + v2
return (v.size == 2 && v[0] == "foo" && v[1] == "bar")
}