# = injecting.rb
#
# CREDIT Louis J Scoras

module Enumerable

  # Say you want to count letters--
  #
  #    some_text.injecting(Hash.new(0) {|h,l| h[l] += 1}
  #
  # vs
  #
  #    some_text.inject(Hash.new(0)) {|h,l| h[l] +=1; h}
  #

  def injecting(s)
    inject(s) do |k, i|
      yield(k, i); k
    end
  end

end
