Skip to content

rauschma/op_overload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Fake operator overloading for JavaScript

The type Point uses fake operator overloading and lets you do the following:

var Point = require("./point.js").Point;
var p = new Point();

p._ = new Point(1, 2) + new Point(3, 4) + new Point(5, 6);
console.log(p.toString()); // Point(9, 12)

Caveats:

  • The overloaded operators only work when used together with an assignment, in the above manner.
  • "" + mypoint won't invoke toString(), but valueOf(). Work-around: "" + mypoint._

Releases

No releases published

Packages

No packages published