From: Peter Li Date: 2009-08-20T23:45:18+09:00 Subject: Re: how exit a block? Thomas B. wrote: > > Your question is not what you really want to ask about. > > You don't want to exit the block. You want to exit the loop that is > inside the each method. And you break out from loops using break. > > Just exiting the block would be useless, because you would still be > inside the loop, and the each would just go on to the next iteration. In > fact, you exit the block each time control gets to the end of the block > normally, but then the block is called again in the next iteration. Note, in some situations next is exactly what you want: mixed_collection.sort do |x,y| next x.class.name <=> y.class.name if x.class != y.class x <=> y end As you say though, other times next would be pointless and you want break. Best, P -- Posted via http://www.ruby-forum.com/.