Files
kotlin-fork/js/js.translator/testData/examples/cases/extensionClosure.kt
T
Denis Zharkov 73799e2c3c Replace deprecated lambda syntax in testData
It's done with similar constructions where possible trying to preserve
intended behavior.
Some usages are removed because they test exactly the feature that
we are going to drop soon.
2015-09-25 08:29:25 +03:00

14 lines
310 B
Kotlin
Vendored

class Point(val x: Int, val y: Int)
fun box(): String {
val answer = apply(Point(3, 5), { scalar: Int ->
Point(x * scalar, y * scalar)
})
return if (answer.x == 6 && answer.y == 10) "OK" else "FAIL"
}
fun apply(arg: Point, f: Point.(scalar: Int) -> Point): Point {
return arg.f(2)
}