Files
kotlin-fork/compiler/testData/psi/examples/UpdateOperation.kt
T

14 lines
371 B
Kotlin
Vendored

class Pair(x : Int, y : Int) {
companion 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