## How to sum array of numbers in Ruby?

There are different ways to achieve this: Imagine that you have: a = [1, 2, 3] Using sum a.sum Using inject a.inject(0) { |sum, x| »

There are different ways to achieve this: Imagine that you have: a = [1, 2, 3] Using sum a.sum Using inject a.inject(0) { |sum, x| »