Madamadam Madamadam - 2 months ago 6
Ruby Question

Removing all elements of a column in a two-dimensional array

I have this array:

arr = [["a","b","c"],[2,3,5],[3,6,8],[1,3,1]]

which is representing a prawn-table containing columns "a", "b", and "c".

How do I remove the entire column "c" with all its values, 5, 8, 1?

Maybe there are useful hints in "Create two-dimensional arrays and access sub-arrays in Ruby" and "difficulty modifying two dimensional ruby array" but I can't transfer them to my problem.


Just out of curiosity sake here is an another approach (one-liner):