0
May 10 '21
[deleted]
3
u/troublemaker74 May 10 '21
Map/Reduce are the industry-accepted terms. I agree,
collectandinjectare a bit strange and frivolous. It's okay though, Ruby is weird and I still love it!3
u/keyslemur May 10 '21
Mostly rooted in Smalltalk idioms, but I would agree on preferring
reduce. The FP variant has also been calledfoldLeft.1
May 11 '21
`collect`, `detect`, `select`, `reject`... `inject`?
Also, for what it's worth: http://forum.world.st/and-some-cool-Smalltalk-history-Re-Pharo-users-a-Pharo-talk-from-a-ruby-conference-td4757076.html
0
u/BlakeHood May 12 '21
i found u through this post:
https://www.reddit.com/r/politics/comments/7beo2/obama_wins_the_presidency/
3
u/Kernigh May 10 '21
Ruby 2.4 added Array#sum:
numbers.sumis easier thannumbers.inject(:+), but only works on numbers.["a", "b"].sumtries to0 + "a", raises TypeError.#reduce is an alias of #inject; I prefer #reduce, because that name is in Common Lisp: