mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-19 03:44:23 -05:00
using 'where' for array comprehension filtering, after kamatsu's suggestion -- execution tests pass now with significant whitespace
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
nums: n * n for n in [1, 2, 3] if n % 2 isnt 0.
|
||||
results: n * 2 for n in nums.
|
||||
nums: n * n for n in [1, 2, 3] where n % 2 isnt 0
|
||||
results: n * 2 for n in nums
|
||||
|
||||
# next: for n in [1, 2, 3] if n % 2 isnt 0
|
||||
# print('hi') if false
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
func: =>
|
||||
a: 3
|
||||
b: []
|
||||
|
||||
while a >= 0
|
||||
b.push('o')
|
||||
a--
|
||||
@@ -20,7 +21,7 @@ func: =>
|
||||
text = c.text
|
||||
}
|
||||
|
||||
c.list: l for l in d.text.split('') if l is '-'
|
||||
c.list: l for l in d.text.split('') where l is '-'
|
||||
|
||||
c.single: c.list[1..1][0]
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
nums: i * 3 for i in [1..3].
|
||||
nums: i * 3 for i in [1..3]
|
||||
|
||||
negs: x for x in [-20..-10].
|
||||
negs: x for x in [-20..-10]
|
||||
negs: negs[0..2]
|
||||
|
||||
result: nums.concat(negs).join(', ')
|
||||
|
||||
Reference in New Issue
Block a user