Three Monkeys, Three Typewriters, Two Days

Comments: Array.map + destructuring assignment = win

Indeed-o!

Posted by mmc at April 16, 2008 3:40 AM

Actually, I think you can do it nicer, and maybe even perfier, but you need to switch js1.7 on:

function enumURLPairs(list) {
for each (var tuple in list) {
do_check_eq(tuple.length, 2);
yield tuple.map(stringToURL);
}
}

for each (var [provided, target] in enumURLPairs(paris) {
// do foo
}

This way you don't create the intermediate array.

PS: Sorry, I don't think I can indent.

Posted by Axel Hecht at April 16, 2008 8:17 AM
Post a comment