Re:Proof You Can Become a Better Programmer
by bshimmin on Sunday November 27, 2016 @11:02AM
(#13049795)
What on earth does he mean by saying that "the reduce method [instead of inject] is performance friendly and a more "Ruby way" of doing things"? `reduce` is an alias for `inject`...
[ Parent
| on HN ]
Re:Proof You Can Become a Better Programmer
by jaredharley on Sunday November 27, 2016 @11:15AM
(#13049859)
Based on the linked github page[1], it looks like that comment was an extrapolation from a guideline in Airbnb's Ruby Style Guide, where Airbnb prefers the use of `reduce` instead of `inject`:
- Prefer `reduce` over `inject`.
I haven't seen any other evidence to show reduce is more performance friendly.
Re:Proof You Can Become a Better Programmer
by bshimmin on Sunday November 27, 2016 @11:23AM
(#13049910)
How could it be..? https://github.com/ruby/ruby/blob/ruby_2_3/enum.c#L3509-L351...
I prefer `reduce` too, because it feels conceptually easier to understand (similarly `foldl`, though Ruby doesn't have that).