Skip to content

Commit ec77a16

Browse files
committed
Merge pull request coffeescript-cookbook#30 from krawaller/master
Removing some unnecessary invocation parens
2 parents 68f5867 + 17b13d8 commit ec77a16

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

chapters/arrays/concatenating-arrays.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Use JavaScript's Array concat() method:
1414
{% highlight coffeescript %}
1515
ray1 = [1,2,3]
1616
ray2 = [4,5,6]
17-
ray3 = ray1.concat(ray2)
17+
ray3 = ray1.concat ray2
1818
# => [1, 2, 3, 4, 5, 6]
1919
{% endhighlight %}
2020

chapters/arrays/max-array-value.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ In ECMAScript 5, use `Array#reduce`. In older javascripts, use Math.max over a l
1313

1414
{% highlight coffeescript %}
1515
# ECMAScript 5
16-
[12,32,11,67,1,3].reduce (a,b) -> Math.max(a,b)
16+
[12,32,11,67,1,3].reduce (a,b) -> Math.max a, b
1717
# => 67
1818

1919
# Pre-EC5

chapters/math/fast-fibonacci.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ fib_bits = (n) ->
5252

5353
bits = []
5454
while n > 0
55-
[n, bit] = divmodBasic(n, 2)
56-
bits.push(bit)
55+
[n, bit] = divmodBasic n, 2
56+
bits.push bit
5757

5858
bits.reverse()
5959
return bits
@@ -67,7 +67,7 @@ fibFast = (n) ->
6767

6868
[a, b, c] = [1, 0, 1]
6969

70-
for bit in fib_bits(n)
70+
for bit in fib_bits n
7171
if bit
7272
[a, b] = [(a+c)*b, b*b + c*c]
7373
else
@@ -88,12 +88,12 @@ divmodBasic = (x, y) ->
8888
Burnikel / Ziegler _if_ possible...
8989
###
9090

91-
return [(q = Math.floor(x/y)), (r = if x < y then x else x % y)]
91+
return [(q = Math.floor x/y), (r = if x < y then x else x % y)]
9292

9393
start = (new Date).getTime();
9494
calc_value = fibFast(MAXIMUM_JS_FIB_N)
9595
diff = (new Date).getTime() - start;
96-
console.log("[#{calc_value}] took #{diff} ms.")
96+
console.log "[#{calc_value}] took #{diff} ms."
9797
{% endhighlight %}
9898

9999
## Discussion

chapters/metaprogramming/detecting-and-replacing-functions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Use `::` to detect the function, and assign to it if it does not exist.
1414
{% highlight coffeescript %}
1515
unless Array::filter
1616
Array::filter = (callback) ->
17-
element for element in this when callback(element)
17+
element for element in this when callback element
1818

1919
array = [1..10]
2020

chapters/strings/finding-substrings.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ You need to find the first or last occurrence of a search string within a messag
1010
## Solution
1111

1212
Use Javascript's indexOf() and lastIndexOf() to find the first and last occurrences of a string, respectively.
13-
Syntax: string.indexOf(searchstring, start)
13+
Syntax: string.indexOf searchstring, start
1414

1515
{% highlight coffeescript %}
1616
message = "This is a test string. This has a repeat or two. This might even have a third."
17-
message.indexOf("This",0)
17+
message.indexOf "This", 0
1818
# => 0
1919

2020
# Modifying the start parameter
21-
message.indexOf("This",5)
21+
message.indexOf "This", 5
2222
# => 23
2323

24-
message.lastIndexOf("This")
24+
message.lastIndexOf "This"
2525
# => 49
2626

2727
{% endhighlight %}

chapters/strings/repeating.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Create an array of n+1 nulls, and then join it with the repetition string as the
1313

1414
{% highlight coffeescript %}
1515
# create a string of 10 foos
16-
Array(11).join('foo')
16+
Array(11).join 'foo'
1717

1818
# => "foofoofoofoofoofoofoofoofoofoo"
1919
{% endhighlight %}

0 commit comments

Comments
 (0)