From: timsuth@... (Tim Sutherland) Date: 2004-01-17T15:15:04+09:00 Subject: Re: Concatenating variable number of Arrays ? In article <1074168191.4130.26.camel@lambda.eavesdrop.ping.de>, Florian Frank wrote: >On Wed, 2004-01-14 at 16:33, Johan Holmberg wrote: >> The best way I have found until now, of doing what I want is >> >> arr2 = arr1.inject([]) {|acc,x| acc.concat x} > >You can also use "+" here: > >arr2 = arr1.inject([]) { |a,x| a + x } [...] If you're going to do this then you might want to define `sum': class Array def sum(start) inject(start) { |a, x| a + x } end end Then you can do arr2 = arr1.sum([]) Of course, as Robert Klemme says, this creates many temporary arrays.