6 ms·
> array and generator comprehension: [a+b for (a in A) for (b in B)] (array comprehension), (x for (x of generateValues()) if (x.color === 'blue')) (generator e
by adrusi 12y ago
> array and generator comprehension: [a+b for (a in A) for (b in B)] (array comprehension), (x for (x of generateValues()) if (x.color === 'blue')) (generator expression).
Bit of an error here. The array comprehension uses "in" which will iterate over the indexes of A and B. While this is technically valid, no one would look at that and expect it to return the string concatenation of all the indexes of A and B :)
- espadrine 12y agoYou're right; I didn't update the example while the syntax was in flux. Fixed! ☺ (There's no certainty that the syntax will be kept, though, see this[1] about deferring it to ES7 to generalize the syntax for parallelism, and this[2] to make async promises and generators work together.) [1]: https://speakerdeck.com/dherman/a-better-future-for-comprehensions https://speakerdeck.com/dherman/a-better-future-for-comprehe... [2]: https://docs.google.com/file/d/0B4PVbLpUIdzoMDR5dWstRllXblU/edit https://docs.google.com/file/d/0B4PVbLpUIdzoMDR5dWstRllXblU/...