From: Pit Capitain Date: 2005-11-26T06:07:25+09:00 Subject: Re: Faster way to pick the every other array member? Damphyr schrieb: > we have [1,2,3,4,5,6,7] and want [2,4,6] > > Is there a way other than > > fields=[1,2,3,4,5,6,7] > fields.collect!{|f| > f if fields.index(f)%2==1 > }.compact! > > And by another way I mean something shorter and more beautiful :). fields.values_at(*(0...fields.size).select{|i|i%2==1}) Regards, Pit