2 ms·
Would (1..100).fold(&:+) be more obvious? How about (1..100).reduce(&:+)? If either one of those makes sense, perhaps it is a question of Matz choosing Smalltal
by raganwald 19y ago
Would (1..100).fold(&:+) be more obvious? How about (1..100).reduce(&:+)? If either one of those makes sense, perhaps it is a question of Matz choosing Smalltalk's names for methods (collect, select, detect, reject, inject).
Please let me know if changing the name of the method doesn't help.
- spydez 19y agoA little explanation in your article would've been fine. The non-ruby people in the crowd have no clue what "&:+" does, so you lost us really early on when you neglected to explain your fancy one-liner. 'inject' makes sense (in retrospect), but until it was explained, I had no clue why injecting symbol soup into a range of integers was interesting.
- raganwald 19y ago"I had no clue why injecting symbol soup into a range of integers was interesting." Lisp flavours? "A little explanation in your article would've been fine." Done, thank you.