DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Sum An Array In Ruby 1.9

03.01.2010
| 2404 views |
  • submit to reddit
        Source: <a href="http://stackoverflow.com/questions/1538789/how-to-sum-array-members-in-ruby/1538949#1538949">How to sum array members in Ruby?</a> [stackoverflow.com]

array = [1,2,3]
array.inject(:+)