面试题答案
一键面试data class Point(val x: Int, val y: Int) {
operator fun plus(other: Point): Point {
return Point(this.x + other.x, this.y + other.y)
}
}
你可以这样使用:
fun main() {
val point1 = Point(1, 2)
val point2 = Point(3, 4)
val result = point1 + point2
println("Result: x = ${result.x}, y = ${result.y}")
}