Skip to content

Commit ca0b5a4

Browse files
committed
vec class should be immutable
1 parent 7fe6361 commit ca0b5a4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

linear-algebra/vec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Vec.prototype.sameSize = function(vec) {
1515
};
1616

1717
Vec.prototype.toFixed = function(size) {
18-
this.comps = this.comps.map(comp => comp.toFixed(size));
19-
return this;
18+
const comps = this.comps.map(comp => comp.toFixed(size));
19+
return new Vec(comps);
2020
};
2121

2222
Vec.prototype.eq = function(vec) {

0 commit comments

Comments
 (0)