From: botp Date: 2012-06-22T16:36:00+09:00 Subject: Re: inject was Benchmark obsession? On Fri, Jun 22, 2012 at 7:30 AM, Henry Maddocks wrote: > I come across this quite often, especially in Rails apps. > > a = {:list => [1,2,3,4]} > b = {:list => [9,8,7,6,5]} > > c = [a,b] > > c.inject([]) {|memo, run| memo + run[:list] } > > I always cringe when I see it but I haven't found an alternative that is as > clear and concise. > collect and flatten looks ugly. I'd love to be able to do... > > c.collect {|run| *run[:list]} c.collect {|run| run[:list]} . flatten or if there are only few elements, a[:list] + b[:list] kind regards -botp