From: Regg Mr Date: 2006-05-22T19:04:17+09:00 Subject: Re: rubynuby - confused by method name "inject" Leslie Viljoen wrote: > On 5/21/06, Jim Weirich wrote: >> Jeff Pritchard wrote: >> > As for Inject, nobody has come up with a wording that makes any sense to >> > me yet. Does Inject have any aliases/synonyms? >> >> How I remember: Inject takes a binary operation (e.g. +) and injects it >> between each element of a list. >> >> [1,2,3].inject { |a,b| a+b } => 1+2+3 > > Awesome! That really helps me! Seems like "sum" would have been a better name. Also [1,2,3].each {|a| b += a} is easier to read ...for me. -- Posted via http://www.ruby-forum.com/.