4 ms·
Not inject. Inject was borrowed from smalltalk's #inject:into, but dropped the "into" and just ended up being unintuitive for many people. Ruby 1.8.7 and 1.9 no
by davidmathers 17y ago
Not inject. Inject was borrowed from smalltalk's #inject:into, but dropped the "into" and just ended up being unintuitive for many people. Ruby 1.8.7 and 1.9 now have #reduce, so I'd say that's the way to go. No reason to use foldl unless you're going to also have a foldr.
- jashkenas 17y agoVersion 0.2, which should be out this evening, will call it "reduce", and alias it to "inject". Thanks for the feedback.