Kotlin: operator overloading

Example:

data class Point(val x: Int, val y: Int)
Kotlin allows you to provide custom implementations for standard operators.

Solution:

operator fun Point.plus(other: Point): Point = Point(x + other.x, y + other.y) val result = Point(1, 2) + Point(3, 4)

Beginner's Guide to Kotlin