jashkenas--coffeescript/test/fixtures/execution/test_range_comprehension.co...

15 lines
291 B
CoffeeScript
Raw Normal View History

nums: i * 3 for i in [1..3]
2009-12-26 03:16:40 -05:00
negs: x for x in [-20..-5*2]
negs: negs[0..2]
2009-12-26 03:16:40 -05:00
result: nums.concat(negs).join(', ')
print(result is '3, 6, 9, -20, -19, -18')
# Ensure that ranges are safe. This used to infinite loop:
j = 5
result: for j in [j..(j+3)]
j
print(result.join(' ') is '5 6 7 8')