From: nobu.nokada@... Date: 2003-02-03T14:42:40+09:00 Subject: Re: break out of a loop Hi, At Fri, 31 Jan 2003 15:26:39 +0900, Vivek Nallur wrote: > Is there an idiomatic(or more elegant way) of finding out whether I exited > a loop normally or because of an exceptional condition? > > e.g > > 10.times{ > # some processing > > #if (some condition) > break > end > > #further processing > } In simplest case, `break'ed iterator returns nil, otherwise what will be returned depends on its specification and implementation. In this case, Integer#times returns self, so you can write as: finished = 10.times { if some(condition) break end } if finished puts "iterated #{finished} times" else puts "breaked" end -- Nobu Nakada