Sum an array with inject
collection = [1, 2, 3, 4, 5] collection.inject(0) {|sum, i| sum + i} # => 15