Ruby inject method is useful for combining an element inside enumerable, with binary operation and initial value.
For example inject method useful for accumulation in one dimensional array :
from above operation, 0 in inject argument is initial value of initial_variable if you forget to specify an argument in inject method by default first element in enumerable will be used as initial value.
From above example inject method will accumulate all element inside array / collection, which is :
Another example :
Well, from above example you can simplify the operation process by giving operator symbol like :+, :*, :/
Another awesomeness inject method is you can build hash key value from multi dimensional 2xN array, for example :