How to sum array of numbers in Ruby?
Asked 07 September, 2021
Viewed 1.9K times
  • 57
Votes

I have an array of integers.

For example:

array = [123,321,12389]

Is there any nice way to get the sum of them?

I know, that

sum = 0
array.each { |a| sum+=a }

would work.

16 Answer