ruby - Removing all elements of a column in a two-dimensional array -
i have array:
arr = [["a","b","c"],[2,3,5],[3,6,8],[1,3,1]]
which representing prawn-table containing columns "a", "b", , "c".
how remove entire column "c" values, 5, 8, 1?
maybe there useful hints in "create two-dimensional arrays , access sub-arrays in ruby" , "difficulty modifying 2 dimensional ruby array" can't transfer them problem.
just out of curiosity sake here approach (one-liner):
arr.transpose[0..-2].transpose
Comments
Post a Comment