Added + and - operators to the Point class, as well as a better toString
@@ -154,4 +154,15 @@ foreign class Point {
foreign x=(v)
foreign y
foreign y=(v)
+
+ +(other) {
+ if (!(other is Point)) Fiber.abort("Points can only be subtracted from other points.")
+ return Point.new(x + other.x, y + other.y)
+ }
+ -(other) {
+ if (!(other is Point)) Fiber.abort("Points can only be subtracted from other points.")
+ return Point.new(x - other.x, y - other.y)
+ }
+
+ toString { "{%(x), %(y)}" }
}
