Refactor short method

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)

It may work fine for listing, but you’ve named it “sumColumn” which
suggests it should sum the column, which it does not do.

This would sum the column:

def sumColumn(arr, idx)
arr.inject(0){ |sum, array| sum + array[idx] }
end

This is a simpler way of printing the values:

def putsColumn(arr, idx)
arr.each{ |array| puts array[idx] }
end