Comment Comment by jdougan Ruby inject appears to be derived from Smalltalk #inject:into:#(1 2 3 4 5 6 7) inject: 10 into: [ :sum :each | sum + each squared ].or from your example:someHash := myArray inject: (Dictionary new) into: [ :accumulator :item | ... ].The way I remember the order is it reflects the assignment you'd do is a while loop, sum := sum + each. parent jdougan 1 month ago
#(1 2 3 4 5 6 7) inject: 10 into: [ :sum :each | sum + each squared ].
or from your example:
someHash := myArray inject: (Dictionary new) into: [ :accumulator :item | ... ].
The way I remember the order is it reflects the assignment you'd do is a while loop, sum := sum + each.