using 'where' for array comprehension filtering, after kamatsu's suggestion -- execution tests pass now with significant whitespace

This commit is contained in:
Jeremy Ashkenas
2009-12-29 08:52:26 -05:00
parent cea417de02
commit 3fbb870d01
6 changed files with 26 additions and 21 deletions

View File

@@ -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