I have an array arr = [[1,2],[3,4]] and a column col = [5,6]
Is there an easy way to get an output of [[1,2,5],[3,4,6]] without looping? Thanks
Yes, using Array#transpose as follows:
arr = [[1,2],[3,4]]
col = [5,6]
pp (arr.transpose << col).transpose # => [[1, 2, 5], [3, 4, 6]]