Skip to content

Commit d677d44

Browse files
author
Bozhidar Batsov
committed
fixes #69 - prefer reduce over inject
1 parent d31f312 commit d677d44

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ syntax.
526526
(i.e. `Array#empty?`).
527527
* The names of potentially "dangerous" methods (i.e. methods that modify `self` or the
528528
arguments, `exit!`, etc.) should end with an exclamation mark.
529-
* When using `inject` with short blocks, name the arguments `|a, e|`
529+
* When using `reduce` with short blocks, name the arguments `|a, e|`
530530
(accumulator, element).
531531
* When defining binary operators, name the argument `other`.
532532
@@ -536,9 +536,13 @@ syntax.
536536
end
537537
```
538538
539-
* Prefer `map` over *collect*, `find` over *detect*, `select` over
540-
*find_all*, `size` over *length*. This is not a hard requirement; if the
541-
use of the alias enhances readability, it's ok to use it.
539+
* Prefer `map` over `collect`, `find` over `detect`, `select` over
540+
`find_all`, `reduce` over `inject` and `size` over `length`. This is
541+
not a hard requirement; if the use of the alias enhances
542+
readability, it's ok to use it. The rhyming methods are inherited from
543+
Smalltalk and are not common in other programming languages. The
544+
reason the use of `select` is encouraged over `find_all` is that it
545+
goes together nicely with `reject` and its name is pretty self-explanatory.
542546

543547
## Comments
544548

0 commit comments

Comments
 (0)