Posts

Showing posts with the label array

concat multiple arrays

hi, joining multiple arrays is easy using "+" we can do that using a single method as follows, class Array def concat_multi *lists lists.each {|list| self.concat(list) } end end a = [1, 2, 3] b = [4, 5, 6] c = [7, 8, 9] d = [10, 11] a.concat_multi(b, c, d) p a