Files
kotlin-fork/compiler/testData/psi/examples/UpdateOperation.kt
T
2013-09-17 18:10:00 +04:00

14 lines
367 B
Kotlin

class Pair(x : Int, y : Int) {
class object {
fun copy(from : Pair, x : Int = from.x, y : Int = from.y) = Pair(x, y)
}
}
// One can say:
val p = Point(1, 2)
val p1 = Point.Copy(p, x = 2)
val p2 = Point.Copy(p1, y = -1)
val p3 = Point.Copy(p)
// Such copy(...) methods can be automatically generated by the compiler
// whenever there is a primary constructor