Skip to content

Instantly share code, notes, and snippets.

@CarlosEspejo
Created February 4, 2013 05:03
Show Gist options
  • Save CarlosEspejo/4705107 to your computer and use it in GitHub Desktop.
Save CarlosEspejo/4705107 to your computer and use it in GitHub Desktop.
List Comprehension in Coffee Script
// Coffee script
books = [1..25]
data = (book for book in books)
console.log data
// Generated Javascript
(function() {
var book, books, data, _i, _results;
books = (function() {
_results = [];
for (_i = 1; _i <= 25; _i++){ _results.push(_i); }
return _results;
}).apply(this);
data = (function() {
var _j, _len, _results1;
_results1 = [];
for (_j = 0, _len = books.length; _j < _len; _j++) {
book = books[_j];
_results1.push(book);
}
return _results1;
})();
console.log(data);
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment