mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-18 11:31:20 -05:00
first draft of optional parentheses, with a couple tests ... more to follow
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
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')
|
||||
print results.join(',') is '2,18'
|
||||
|
||||
|
||||
obj: {one: 1, two: 2, three: 3}
|
||||
names: prop + '!' for prop of obj
|
||||
odds: prop + '!' for prop, value of obj when value % 2 isnt 0
|
||||
|
||||
print(names.join(' ') is "one! two! three!")
|
||||
print(odds.join(' ') is "one! three!")
|
||||
print names.join(' ') is "one! two! three!"
|
||||
print odds.join(' ') is "one! three!"
|
||||
|
||||
|
||||
evens: for num in [1, 2, 3, 4, 5, 6] when num % 2 is 0
|
||||
@@ -17,12 +17,12 @@ evens: for num in [1, 2, 3, 4, 5, 6] when num % 2 is 0
|
||||
num -= 2
|
||||
num * -1
|
||||
|
||||
print(evens.join(', ') is '4, 6, 8')
|
||||
print evens.join(', ') is '4, 6, 8'
|
||||
|
||||
|
||||
# Make sure that the "in" operator still works.
|
||||
|
||||
print(2 in evens)
|
||||
print 2 in evens
|
||||
|
||||
|
||||
# When functions are being defined within the body of a comprehension, make
|
||||
@@ -37,6 +37,6 @@ for method in methods
|
||||
obj[name]: =>
|
||||
"I'm " + name
|
||||
|
||||
print(obj.one() is "I'm one")
|
||||
print(obj.two() is "I'm two")
|
||||
print(obj.three() is "I'm three")
|
||||
print obj.one() is "I'm one"
|
||||
print obj.two() is "I'm two"
|
||||
print obj.three() is "I'm three"
|
||||
|
||||
Reference in New Issue
Block a user