From: C Erler Date: 2007-07-11T17:33:17+09:00 Subject: Re: Choice of the word "inject" vs what the method actually does (method naming) On Jul 4, 7:32 am, "Wayne E. Seguin" wrote: > Yes I realize that an alias may be used for this, however, I am > looking for insight as to the reason "inject" was chosen over > something better suited like accumulate. The general idea is that you have an unfinished result. You inject each item one at a time into the result. [1, 2, 3].inject(0) { |sum, item| sum + item } injects each item into the sum one at a time. [String, Array, Hash].inject({}) { |class_lookup, klass| class_lookup[klass.name] = klass } injects an entry into the lookup table one at a time. [egg, sugar, salt].inject { |mixture, ingredient| mixture.mix_in ingredient } injects an ingredient into the mixture one at a time.