Robert Dober wrote: > On 2/12/07, Eric I. <rubytraining / gmail.com> wrote: >> >> On Feb 12, 1:07 am, "Phrogz" <g... / refinery.com> wrote: >> > On Feb 11, 4:40 pm, Alex Young <a... / blackkettle.org> 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