From: Drew Olson Date: 2008-03-08T06:38:53+09:00 Subject: Re: ActiveSupport Enumerable#sum should not use #size Stefan Lang wrote: > inject takes the identity as first parameter: > > inject(identity) { |sum, element| sum + element } > > and since they define Symbol#to_proc, this can even be > > inject(identity, &:+) > >> end >> end >> >> Look right? >> >> >> T. > > Stefan This is very concise, but doesn't have the same behavior as the original sum. This will start any sum with the identity and then build on it from there. Not that this is incorrect behavior, it's just different from what was originally defined. For example: a = [1,2,3] original sum, with identity = 10, would return 6, whereas your version would return 16. - Drew -- Posted via http://www.ruby-forum.com/.