From: Csaba Henk Date: 2005-06-21T00:05:50+09:00 Subject: Re: Iterate with condition On Tue, Jun 21, 2005 at 12:00:36AM +0900, Robert Klemme wrote: > Csaba Henk wrote: > > Maybe > > > > cl.each_with_index { |e,i| > > i < n or break > > c = _openChat(e.customer_id, @session[:user].id) and chats << c > > } > > Nah, this cries for #inject! > > found = collection.inject([]) do |f,x| > if check_condition(x) > f << x > break f if f.size >= 10 > end > f > end I see, you are right -- the counter should tick only if a "non-void" entry is fetched. Csaba