Skip to content

Commit 92a105c

Browse files
committed
Corrected a minor bug as pointed out by @MaskRay
1 parent 4f45abc commit 92a105c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

chapters/design_patterns/strategy.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ Given an unsorted list, for example, we can change the sorting algorithm under d
1616
###The base class:
1717

1818
{% highlight coffeescript %}
19-
StringSorter = (@algorithm) ->
20-
sort: (list) -> @algorithm list
19+
StringSorter = (algorithm) ->
20+
sort: (list) -> algorithm list
2121
{% endhighlight %}
2222

2323
###The strategies:
@@ -26,7 +26,7 @@ StringSorter = (@algorithm) ->
2626
bubbleSort = (list) ->
2727
anySwaps = false
2828
swapPass = ->
29-
for r in [0..list.length-1]
29+
for r in [0..list.length-2]
3030
if list[r] > list[r+1]
3131
anySwaps = true
3232
[list[r], list[r+1]] = [list[r+1], list[r]]

0 commit comments

Comments
 (0)