Swift style syntax

Yongxu Ren renyongxu at gmail.com
Fri Oct 16 01:40:56 UTC 2015


I vote for operator overloading!

I think this is probably going to be a good way to do it:
```
//in local scope
let operator(**) = (lhs,rhs) => Math.pow(lhs,rhs);

//class method
Complex.prototype.operator(+) = function(lhs,rhs){
  return new Complex(lhs.r+rhs.r,lhs.i+rhs.i);
}

//global, may not be an good idea
operator(+) = (lhs,rhs) => lhs*rhs;
```
//this will work for case above
names.sort(>)
```
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20151015/abeafa08/attachment.html>


More information about the es-discuss mailing list