--1926193751-1814797446-12482161012679
Content-Type: MULTIPART/MIXED; BOUNDARY="1926193751-1814797446-1248216101=:22679"

  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--1926193751-1814797446-12482161012679
Content-Type: TEXT/PLAIN; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8BIT

Hi --

On Wed, 22 Jul 2009, lphä Blüë wrote:

>  def product
>    @arr.inject {|a,b| a * b }
>  end

>  product, sum  .0, 0.0
>  arr.each do |a|
>    sum + 
>    product + *a
>  end

The logic in the second snippet is wrong (assuming the logic in the
product method is what you want). Try it with [1,2], for example, and
you'll get 2 for the first one and 5 for the second.


David

-- 
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
Now available: The Well-Grounded Rubyist (http://manning.com/black2)
Training! Intro to Ruby, with Black & Kastner, September 14-17
(More info: http://rubyurl.com/vmzN)
--1926193751-1814797446-12482161012679--
--1926193751-1814797446-12482161012679--