From: Stefano Crocco Date: 2009-02-10T18:15:50+09:00 Subject: Re: a better way to do this job? Alle Tuesday 10 February 2009, Zhenning Guan ha scritto: > topics.each do |f| > times +=1 > puts f.title > if times > 4 > break > > > a little ugly, doesn't it? If topics is an array, you can use: topics[0..4].each{|f| puts f.title} Another option, which can be used for any Enumerable object is: topics.each_with_index do |f, i| puts f.title break if i > 4 end While not as nice as the first version, it's a bit clearer than your code. I hope this helps Stefano