Last active
January 4, 2018 15:12
-
-
Save littledan/19c09a09d2afe7558cdfd6fdae18f956 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Vec { | |
#x; | |
#y; | |
#z; | |
constructor(x, y, z) { | |
this.#x = x; | |
this.#y = y; | |
this.#z = z; | |
} | |
static #operators = { | |
"+"(a, b) { return new Vec(a.#x + b.#x, a.#y + b.#y, a.#z + b.#z); } | |
"-"(a, b) { return new Vec(a.#x - b.#x, a.#y - b.#y, a.#z - b.#z); } | |
}; | |
get [Symbol.operators]() { return Vec.#operators } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment