Posts Tagged ‘Accumulator’

Refactoring C# Series: Aggregation of IEnumerable

I was recently reading Programming Ruby: The Pragmatic Programmers’ Guide, Second Edition, and came across this piece of example Ruby code: [1,3,5,7].inject(0) {|sum, element| sum+element} -> 16 [1,3,5,7].inject(1) {|product, element| product*element} -> 105 Inject is a method which acts on an array by aggregating or accumulating the values within that array. It loops through the [...]

More »