operator + method
Adds other
to this Vec.
- If
other
is a Vec or Direction, adds each pair of coordinates. - If
other
is an int, adds that value to both coordinates.
Any other type is an error.
Implementation
Vec operator +(Object other) => switch (other) {
Vec _ => Vec(x + other.x, y + other.y),
int _ => Vec(x + other, y + other),
_ => throw ArgumentError("Operand must be an int or Vec.")
};