From: James Coglan Date: 2008-10-03T21:24:19+09:00 Subject: Re: Iterate over array and add numbers of each object ------=_Part_21707_24893730.1223036741448 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline > number = 0; > objects.each do |o| > number += o.some_number > end > return number > > I guess there's a much more beautiful way for this, or isn't? Something > like collect or so... number = objects.inject(0) { |sum, obj| sum + obj.some_number } ------=_Part_21707_24893730.1223036741448--