From: Alex Young Date: 2007-02-13T02:17:29+09:00 Subject: Re: One-Liners (#113) Robert Dober wrote: > On 2/12/07, Eric I. wrote: >> >> On Feb 12, 1:07 am, "Phrogz" wrote: >> > On Feb 11, 4:40 pm, Alex Young wrote: >> > >> > > # One-level flatten(). >> > > r=[];quiz.each{|a|r+=[*a]};r >> > >> > Elegantly small! >> >> When I saw that, I thought that it could definitely be shortened by >> using an inject. After all, there'd be no assignments of r, no final >> returning of r, no semicolons. But when all was said and done, it >> ended up being the same length. Compare: >> >> quiz.inject([]){|r,a|r+[*a]} Given the equal lengths, I prefer this - the r=[];...;r idiom strikes me as rather ugly. >> r=[];quiz.each{|a|r+=[*a]};r >> >> Oh well.... >> >> Eric > > > Comparing this with James' solution we can it down to > quiz.inject{|r,a|[*r]+[*a]} Wow :-) -- Alex