APXEOLOG
11/12/2018, 2:33 PMclass Vector2<T : Number>(val x: T, val y: T) {
operator fun plus(vector2: Vector2<Number>): Vector2<T> {
return Vector2(x + vector2.x, y + vector2.y) // Doesn't compile
}
}
fun main(args: Array<String>) {
Vector2(1, 1) + Vector2(2, 2) // Int
Vector2(1.0, 1.0) + Vector2(2.0, 2.0) // Double
Vector2(1, 1) + Vector2(2.0, 2.0) // Ideally second Vector2 type should be casted toInt() here
}
But it'm not sure how to do it