Or even better:

class Array
  def sum1
    initial_val_for_total = 0
    inject(initial_val_for_total) {|total, array_element| total += 
array_element}
  end
end

-- 
Posted via http://www.ruby-forum.com/.