From: Julian Leviston Date: 2009-02-10T21:21:40+09:00 Subject: Re: a better way to do this job? First doesn't take an argument I'm ruby. It does If you're using rails enumerable mixin Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 10/02/2009, at 10:30 PM, Ryan Davis wrote: > > On Feb 10, 2009, at 01:11 , Zhenning Guan wrote: > >> topics.each do |f| >> times +=1 >> puts f.title >> if times > 4 >> break > > there are a lot of ways. My first reaction is: > > topics.first(5).each do |f| > puts f.title > end > > If you define to_s on the topic class to return title then you can do: > > puts topics.first(5) > > and be done with it. > >