Kevin Barabash (2016-05-18T05:30:34.000Z)
kevinb at khanacademy.org (2016-05-18T05:32:39.871Z)
> I'm thinking, instead, static methods should be used. It would be more versatile. I like the idea of passing both operands as arguments (mainly from an aesthetics/symmetry point of view), but I can't think of case where it would be more versatile than instance methods seeing as at least one argument has to be `this`. Could you give an example of when this would be more versatile? Since the new syntax is describing what each type should be, maybe we could leverage existing type syntax from Flow/TypeScript. ```js class Vec2 { constructor(x, y) { this.x = x this.y = y } operator+ (x: Vec2, y: Vec2) { return new this(x.x + y.x, x.y + y.y) } operator+ (x: Vec2, y: number) { return new this(x.x + y, x.y + y) } operator+= (x: Vec2, y: Vec2) { x.x += y.x x.y += y.y } operator+= (x: Vec2, y: number) { x.x += y x.y += y } // #number += this -> x = x + this operator- (x: Vec2) { return new this(-x.x, -x.y) } // etc... } class Vec3 { // ... operator+ (x: Vec3, y: Vec2) { return new this(x.x + y.x, x.y + y.y, x.z) } // etc... } ``` On Mon, May 16, 2016 at 12:33 PM, Isiah Meadows <isiahmeadows at gmail.com> wrote: