I am trying to find sum of each array.
(1..9).to_a.combination(3).to_a.each{ |item| item.inject{:+}}
But my code gives the followings.
[[1, 2, 3], [1, 2, 4], [1, 2, 5], [1, 2, 6], [1, 2, 7], [1, 2, 8], [1, 2, 9],
[1, 3, 4], [1, 3, 5], [1, 3, 6], [1, 3, 7], [1, 3, 8], ...
What I am expecting is something like this.
[6, 7, 8, 9,...]
How can I find sum of each array?
summethod like(1..9).to_a.combination(3).map{|a| a.sum(0)}