Hi I have this short program to list the integers of a column in a 2d
arrays. It works fine but I feel as if I wrote it very innefficiently
and I would like to refactor it to make it look more ruby.
Thanks you
def sumColumn(arr, columnIndex)
i = 0
arr.each do |x|
x.each do |cell|
puts cell if columnIndex == i
i = i+1
i = 0 if i == arr[0].length
end
end
end
values = Array[[10, 20, 30], [40, 50, 60]]
sumColumn(values, 1)