Timothy Hunter wrote: > GáÃor SEBESTY¥ÎN wrote: >> How can I do it in Ruby? I know objs.each do |anObj| ... end but it's >> not (enough) good for me. I want to use additional cycle condition >> like this: >> >> boolean b = true; >> Iterator it = objs.iterator(); >> while (b && it.hasMore()) { >> Object anObj = it.next(); >> ... >> } > > The break statement terminates a loop. > > b = true > foo.each { b = do_something(); break unless b} return works as well if in a method def sample foo.each {|x| return x if do_something(x) } end There are other methods that may suit depending on Gabor's requirements: #find, #select, #any?, #all? ... What exactly do you want to do with the collection? Kind regards robert