Go to content Go to sidebar

inject, inject, inject

If inject had a better name, then it would be easier for us rookies to remember that it's the right way to accumulate values across an array:

irb(main):001:0> (1..10).inject(0) { |s,v| s += v }
=> 55

Might I suggest something along the line of: