diff --git a/documentation/coffee/array_comprehensions.coffee b/documentation/coffee/array_comprehensions.coffee index fb4934bf..ddda9319 100644 --- a/documentation/coffee/array_comprehensions.coffee +++ b/documentation/coffee/array_comprehensions.coffee @@ -2,7 +2,4 @@ lunch: food.eat() for food in ['toast', 'cheese', 'wine']. # Zebra-stripe a table. -highlight(row) for row, i in table if i % 2 is 0. - -# Check the first one hundred combinations. -lockpick(combinations[i]) for i in [1..100]. \ No newline at end of file +highlight(row) for row, i in table if i % 2 is 0. \ No newline at end of file diff --git a/documentation/index.html.erb b/documentation/index.html.erb index b7fad1dd..4524331f 100644 --- a/documentation/index.html.erb +++ b/documentation/index.html.erb @@ -357,6 +357,11 @@ coffee --print app/scripts/*.coffee > concatenation.js would use a loop, each/forEach, map, or select/filter.

<%= code_for('array_comprehensions') %> +

+ If you're not iterating over an actual array, you can use a range to + specify the start and end of an array comprehension: + coundown(i) for i in [10..1]. +

Slicing Arrays with Ranges diff --git a/documentation/js/array_comprehensions.js b/documentation/js/array_comprehensions.js index 8d13577e..636ccb49 100644 --- a/documentation/js/array_comprehensions.js +++ b/documentation/js/array_comprehensions.js @@ -1,5 +1,5 @@ (function(){ - var __a, __b, __c, __d, __e, __f, __g, __h, __i, __j, __k, __l, food, i, lunch, row; + var __a, __b, __c, __d, __e, __f, __g, __h, food, i, lunch, row; // Eat lunch. __a = ['toast', 'cheese', 'wine']; __d = []; @@ -17,10 +17,4 @@ __h[__f] = i % 2 === 0 ? highlight(row) : null; } __h; - // Check the first one hundred combinations. - __k = []; - for (__l=0, i=1, __j=100; i<=__j; i++, __l++) { - __k[__l] = lockpick(combinations[i]); - } - __k; })(); \ No newline at end of file diff --git a/index.html b/index.html index 218452c1..b9ac15f4 100644 --- a/index.html +++ b/index.html @@ -581,10 +581,7 @@ lunch: food.eat() for # Zebra-stripe a table. highlight(row) for row, i in table if i % 2 is 0. - -# Check the first one hundred combinations. -lockpick(combinations[i]) for i in [1..100]. -

var __a, __b, __c, __d, __e, __f, __g, __h, __i, __j, __k, __l, food, i, lunch, row;
+
var __a, __b, __c, __d, __e, __f, __g, __h, food, i, lunch, row;
 // Eat lunch.
 __a = ['toast', 'cheese', 'wine'];
 __d = [];
@@ -602,13 +599,12 @@ __h = [];
   __h[__f] = i % 2 === 0 ? highlight(row) : null;
 }
 __h;
-// Check the first one hundred combinations.
-__k = [];
-for (__l=0, i=1, __j=100; i<=__j; i++, __l++) {
-  __k[__l] = lockpick(combinations[i]);
-}
-__k;
 

+

+ If you're not iterating over an actual array, you can use a range to + specify the start and end of an array comprehension: + coundown(i) for i in [10..1]. +

Slicing Arrays with Ranges