coffeescript Comprehensions


Example

You can do neat things via the results of Array "comprehensions"...

Like assign multiple variables... from the result of a looping for statement...

[express,_] = (require x for x in ['express','underscore'])

Or a syntactically sweet version of a "mapped" function call, etc...

console.log (x.nme for x in [{nme:'Chad',rnk:99}, {nme:'Raul', rnk:9}])

[ 'Chad', 'Raul' ]

Notice the ( ) surrounding these statements. These parenthesis are required to make the enclosed comprehension "work".