From: Lars Haugseth Date: 2012-06-22T16:58:25+09:00 Subject: Re: inject was Benchmark obsession? On 06/22/2012 01: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.flat_map {|run| run[:list]} -- Lars Haugseth