From: George Ogata Date: 2006-12-19T15:33:40+09:00 Subject: Re: DRYing a loop.. On 12/19/06, Josselin wrote: > I wrote that the newbie way, but is there any way to DRY it ? > > closed_cities = [] > 0.step(9, 1) do |i| > closed_cities << City.find_by_id( city_25 [i] [0] ) > i = i.next > end > > if yes, is it only for fun , or does it impact performance (a lot ?) Not sure where the "wet" bit is, but the "i = i.next" is redundant, as 'i' gets assigned on each call of the block. Without knowing more about what each thing is/does, I'd recommend: closed_cities = (0..9).map{|i| City.find_by_id(city_25[i][0])} > thanks for your lights Welcome!