adding a test for multiline-array-comprehension-with-filter

This commit is contained in:
Jeremy Ashkenas 2009-12-31 16:13:52 -05:00
parent 7ec91a1ee5
commit bfd7455db4
1 changed files with 13 additions and 6 deletions

View File

@ -1,14 +1,21 @@
nums: n * n for n in [1, 2, 3] when n % 2 isnt 0
results: n * 2 for n in nums
print(results.join(',') is '2,18')
obj: {one: 1, two: 2, three: 3}
names: key + '!' for value, key in obj
odds: key + '!' for value, key in obj when value % 2 isnt 0
# next: for n in [1, 2, 3] if n % 2 isnt 0
# print('hi') if false
# n * n * 2
print(results.join(',') is '2,18')
print(names.join(' ') is "one! two! three!")
print(odds.join(' ') is "one! three!")
print(odds.join(' ') is "one! three!")
evens: for num in [1, 2, 3, 4, 5, 6] when num % 2 is 0
num *= -1
num -= 2
num * -1
print(evens.join(', ') is '4, 6, 8')