From: redstun Date: 2011-01-23T23:31:23+09:00 Subject: Enumerable.inject_with_index? --001485f46e5a4b0275049a8456d1 Content-Type: text/plain; charset=UTF-8 Enumerable.inject is pretty cool, but it treat the elements as if they have the same weight when doing the calculation, in my case I need to apply a different weight based on the index of each element, therefore I also need the index being provided as one more block parameter. enum.find_index might help, but I think there should be a more direct way to get the index. In short, like for enum.each_entry, there's each_with_index, similarly, for enum.inject, is it possible to have enum.inject_with_index { |memo, obj, index| ... } ? Thanks --001485f46e5a4b0275049a8456d1--