domenic at domenicdenicola.com (2013-09-25T02:34:05.165Z)
Claude, thanks for answering, one correction at bottom: Claude Pache <mailto:claude.pache at gmail.com> September 16, 2013 11:42 AM > P.S. The syntax `[e for e of mySet]` is outdated in Harmony, you should use `[(for let e of mySet) e]`. No, the new syntax is `[for (e of mySet) e]` -- no `let` and parens in the same place as in the for-of/in loop statements.
Claude, thanks for answering, one correction at bottom: > Claude Pache <mailto:claude.pache at gmail.com> > September 16, 2013 11:42 AM > I suggest: > > [ ... mySet ] > > or, if you don't want to use any new syntax: > > Array.from(mySet) > > —Claude > > P.S. The syntax `[e for e of mySet]` is outdated in Harmony, you > should use `[(for let e of mySet) e]`. No, the new syntax is [for (e of mySet) e] -- no let and parens in the same place as in the for-of/in loop statements. /be > > Le 16 sept. 2013 à 17:33, Angus Croll <anguscroll at gmail.com > <mailto:anguscroll at gmail.com>> a écrit : > >> I'm trying to figure out the most painless way, given a set, to >> return the set's values as an array. >> >> Possibilities: >> 1) harmony wiki >> (http://wiki.ecmascript.org/doku.php?id=harmony:iterators&s=iterator >> <http://wiki.ecmascript.org/doku.php?id=harmony:iterators&s=iterator>) suggests >> the following, but it is a syntax error in traceur, continuum and >> "node --harmony" >> >> let arr = [e for e of mySet]; >> >> 2)The ES6 standard supports the following production (i.e. >> expression, not var, before 'for'): >> /IterationStatement : for ( LeftHandSideExpression of >> AssignmentExpression ) Statement/ >> (see >> http://people.mozilla.org/~jorendorff/es6-draft.html#sec-13.6.4.2 >> <http://people.mozilla.org/%7Ejorendorff/es6-draft.html#sec-13.6.4.2>) >> >> which suggests I should be able to do this: >> let arr = []; >> for (arr[arr.length-1] of mySet); >> >> (I can do the equivalent with for-in) but that also errors in the >> above three transpilers >> >> 3) So then I'm left with the pedestrian: >> let arr = []; >> for (e of mySet) { >> arr.push(e); >> } >> >> 4) I also wondered ifArray.from(mySet) would do the trick but again >> doesn't seem to pass muster with any of the above transpilers. >> (continuum returns a zero length array and the other two don't know >> Array.from) >> >> Wondering if I'm missing something better. >> thanks >> >> Angus >> @angustweets >> _______________________________________________ >> es-discuss mailing list >> es-discuss at mozilla.org <mailto:es-discuss at mozilla.org> >> https://mail.mozilla.org/listinfo/es-discuss > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > Angus Croll <mailto:anguscroll at gmail.com> > September 16, 2013 11:33 AM > I'm trying to figure out the most painless way, given a set, to return > the set's values as an array. > > Possibilities: > 1) harmony wiki > (http://wiki.ecmascript.org/doku.php?id=harmony:iterators&s=iterator > <http://wiki.ecmascript.org/doku.php?id=harmony:iterators&s=iterator>) > suggests the following, but it is a syntax error in traceur, continuum > and "node --harmony" > > let arr = [e for e of mySet]; > > 2)The ES6 standard supports the following production (i.e. expression, > not var, before 'for'): > /IterationStatement : for ( LeftHandSideExpression of > AssignmentExpression ) Statement/ > (see http://people.mozilla.org/~jorendorff/es6-draft.html#sec-13.6.4.2 > <http://people.mozilla.org/%7Ejorendorff/es6-draft.html#sec-13.6.4.2>) > > which suggests I should be able to do this: > let arr = []; > for (arr[arr.length-1] of mySet); > > (I can do the equivalent with for-in) but that also errors in the > above three transpilers > > 3) So then I'm left with the pedestrian: > let arr = []; > for (e of mySet) { > arr.push(e); > } > > 4) I also wondered ifArray.from(mySet) would do the trick but again > doesn't seem to pass muster with any of the above transpilers. > (continuum returns a zero length array and the other two don't know > Array.from) > > Wondering if I'm missing something better. > thanks > > Angus > @angustweets > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss