Excerpts from Jonas Pfenniger (zimbatm)'s message of Sun Jan 09 04:08:10 -0800 2011: > 2011/1/9 David J. Hamilton <groups / hjdivad.com>: > > You can abuse break to get a +find+ that acts a little like a hypothetical > > +find_and_map+. > > > > paths = %w( /usr /usr/local /opt /tmp ) > > > > location = paths.find do |path| > > candidate = "#{path}/whatever" > > break candidate if File.exists? candidate > > false > > end > > Haha, that's the best-one :) I underestimate the power of break My version is slightly verbose. As w_a_x_man / yahoo.com implicitly pointed out in their version, the false in the block is actually unnecessary, since the conditional will evaluate to nil, thus allowing the iteration to continue. Break is indeed nice. And of course you can sometimes do the same thing with return, although I think it's usually much cleaner to break out of blocks rather than returning out of them (and the method in which they're evaluated). -- med vänlig hälsning David J. Hamilton