Created
February 4, 2013 05:03
-
-
Save CarlosEspejo/4705107 to your computer and use it in GitHub Desktop.
List Comprehension in Coffee Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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