From: Daniel N Date: 2006-07-26T00:21:47+09:00 Subject: Re: there has got to be a better way... ------=_Part_188023_14582397.1153840902042 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 7/26/06, Michael Barinek wrote: > > i'm looking to simplify the below... > > @tournament.rounds = Array.new(4) { Round.new } > > @tournament.rounds[0].matches = Array.new(8) { Match.new } > @tournament.rounds[1].matches = Array.new(4) { Match.new } > @tournament.rounds[2].matches = Array.new(2) { Match.new } > @tournament.rounds[3].matches = Array.new(1) { Match.new } > > thoughts/suggestions? > > -- > Posted via http://www.ruby-forum.com/. a = [8,4,2,1] @tournament.rounds = 0.upto(3).inject([]) { |round, index| Round.new.matches= Array.new( a[index] ) {Match.new} } I think that should provide the same thing that you have. ------=_Part_188023_14582397.1153840902042--