From: "David A. Black" Date: 2005-05-12T07:38:14+09:00 Subject: Re: object loops and what they return Hi -- On Thu, 12 May 2005, Eric Mahurin wrote: > Consider these loops: > > . { } > > where loop method is each, each_with_index, upto, downto, step, > and probably others. > > Although it is not documented, all of these look to return the > origninal object (collection or int). I think the return values are documented in ri for all of these. [...] > With "each" returning nil, you can also see that many of the > derived loops in Enumerable become trival almost to where you > don't need them. On the other hand, if you were to do this (looking for nil): obj = array.each {|e| break(e) if e.nil? } and each returned nil, you wouldn't know whether you'd succeeded or not. The various find and include? and any? and index methods are probably your best bet for this kind of operation. David -- David A. Black dblack@wobblini.net