multiple return values... like ruby

anders elo anders at kaerus.com
Thu Jan 3 07:26:18 PST 2013


I'd like to propose the incorporation of multiple return values into the ES standard.

function foo(){
  return 1,2,3;
}

let (a,b,c) = foo();

let (a,b) = foo(); // ignore c

let (a,...b) = foo() // a = 1, b = [2,3] 

/* also useful for asynchronous functions returning a promise */
let (response,headers) = yield getAjaxData("http://some.host.com/data");

Thanks! ;)

Vänliga hälsningar / Best regards 
Anders Elo @ kaerus.com



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130103/1d200004/attachment.html>


More information about the es-discuss mailing list