diff --git a/documentation/index.html.erb b/documentation/index.html.erb index 7c52987f..214c9609 100644 --- a/documentation/index.html.erb +++ b/documentation/index.html.erb @@ -479,11 +479,13 @@ Expressions over arrays, objects, and ranges. Comprehensions replace (and compile into) for loops, with optional guard clauses and the value of the current array index. Unlike for loops, array comprehensions are expressions, and can be returned - and assigned. They should be able to handle most places where you otherwise - would use a loop, each/forEach, map, or select/filter. + and assigned.

<%= code_for('array_comprehensions') %>

+ Comprehensions should be able to handle most places where you otherwise + would use a loop, each/forEach, map, or select/filter: + evens = (i for i in list when i % 2 is 0)
If you know the start and end of your loop, or would like to step through in fixed-size increments, you can use a range to specify the start and end of your comprehension. diff --git a/documentation/js/do.js b/documentation/js/do.js index 388f7f95..3e78ff3e 100644 --- a/documentation/js/do.js +++ b/documentation/js/do.js @@ -1,10 +1,10 @@ -var fileName, _fn, _i, _len; -_fn = function(fileName) { - return fs.readFile(fileName, function(err, contents) { - return compile(fileName, contents.toString()); +var filename, _fn, _i, _len; +_fn = function(filename) { + return fs.readFile(filename, function(err, contents) { + return compile(filename, contents.toString()); }); }; for (_i = 0, _len = list.length; _i < _len; _i++) { - fileName = list[_i]; - _fn(fileName); + filename = list[_i]; + _fn(filename); } \ No newline at end of file diff --git a/documentation/js/soaks.js b/documentation/js/soaks.js index f25d85d5..39d37bda 100644 --- a/documentation/js/soaks.js +++ b/documentation/js/soaks.js @@ -1,2 +1,2 @@ var zip, _ref; -zip = typeof lottery.drawWinner === "function" ? (_ref = lottery.drawWinner().address) != null ? _ref.zipcode : void 0 : void 0; \ No newline at end of file +zip = typeof lottery.drawWinner == "function" ? (_ref = lottery.drawWinner().address) != null ? _ref.zipcode : void 0 : void 0; \ No newline at end of file diff --git a/index.html b/index.html index af5067fb..9cd60df3 100644 --- a/index.html +++ b/index.html @@ -752,8 +752,7 @@ alert("The Field: " + rest);;'>run
over arrays, objects, and ranges. Comprehensions replace (and compile into) for loops, with optional guard clauses and the value of the current array index. Unlike for loops, array comprehensions are expressions, and can be returned - and assigned. They should be able to handle most places where you otherwise - would use a loop, each/forEach, map, or select/filter. + and assigned.

# Eat lunch.
 eat food for food in ['toast', 'cheese', 'wine']
@@ -765,6 +764,9 @@ _ref = ['
 }
 
load

+ Comprehensions should be able to handle most places where you otherwise + would use a loop, each/forEach, map, or select/filter: + evens = (i for i in list when i % 2 is 0)
If you know the start and end of your loop, or would like to step through in fixed-size increments, you can use a range to specify the start and end of your comprehension. @@ -911,21 +913,21 @@ lyrics = (function() { provides the do keyword, which immediately invokes a passed function, forwarding any arguments.

-
for fileName in list
-  do (fileName) ->
-    fs.readFile fileName, (err, contents) ->
-      compile fileName, contents.toString()
-
var fileName, _fn, _i, _len;
-_fn = function(fileName) {
-  return fs.readFile(fileName, function(err, contents) {
-    return compile(fileName, contents.toString());
+    
for filename in list
+  do (filename) ->
+    fs.readFile filename, (err, contents) ->
+      compile filename, contents.toString()
+
var filename, _fn, _i, _len;
+_fn = function(filename) {
+  return fs.readFile(filename, function(err, contents) {
+    return compile(filename, contents.toString());
   });
 };
 for (_i = 0, _len = list.length; _i < _len; _i++) {
-  fileName = list[_i];
-  _fn(fileName);
+  filename = list[_i];
+  _fn(filename);
 }
-
load

+
load

@@ -1220,7 +1222,7 @@ footprints = typeof yeti != "undefined" && yeti !== null ? yeti : "bear";;alert(

zip = lottery.drawWinner?().address?.zipcode
 
var zip, _ref;
-zip = typeof lottery.drawWinner === "function" ? (_ref = lottery.drawWinner().address) != null ? _ref.zipcode : void 0 : void 0;
+zip = typeof lottery.drawWinner == "function" ? (_ref = lottery.drawWinner().address) != null ? _ref.zipcode : void 0 : void 0;
 
load

Soaking up nulls is similar to Ruby's @@ -1918,6 +1920,10 @@ task('build:parsercoffeescript-idea — a plugin for IntelliJ IDEA and RubyMine providing syntax highlighting. +

  • + dhotson's coffeescript-jedit + — which provides syntax highlighting support in jEdit. +
  • mattly's rack-coffee — a small Rack middleware for serving CoffeeScript files as @@ -1943,11 +1949,6 @@ task('build:parserHAML templates.
  • -
  • - chrislloyd's Roast - — a CoffeeScript compiler plug-in that allows you to include external - source files. -
  • andrzejsliwa's CoffeeApp — a CoffeeScript wrapper for CouchApps, web applications served