Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Sum An Array In Ruby 1.9

DZone's Guide to

Sum An Array In Ruby 1.9

·
Free Resource
Source: How to sum array members in Ruby? [stackoverflow.com]


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

Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}