From: Joey Date: 2006-05-21T16:32:07+09:00 Subject: Re: rubynuby - confused by method name "inject" ------=_Part_2378_1563915.1148196725065 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline [1,2,3,4,5].inject(0){|sum,num|sum+num} =3D> 15 Which is ((((0+1)+2)+3)+4)+5 j`ey http://www.eachmapinject.com On 5/21/06, Jeff Pritchard wrote: > > Can anybody explain to me how the Enumberable#inject method is > "injecting" something into something? I find it very difficult remember > method names when I don't "get" them. So far in Ruby, "inject" takes > the cake for least understandable method name (with my own particular > convoluted gray matter). > > Can somebody give some examples of its use and state in words how it is > "injecting" something into something? > > thanks, > jp > > P.S. > If anybody wants to take a stab at "collect", that would be welcome > also. > > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_2378_1563915.1148196725065--