From: Anurag Priyam Date: 2011-01-09T08:44:44+09:00 Subject: Re: Best way for Array#find+transform ? > I know I can come up with a new method on Array that would shorten this to: > > ------ > abs_file = paths.find_transform do |path| >  path = File.join(path, filename) >  File.exist?(path) && path > end > ------ > > But is there an existing method that I oversaw that does about the same ? > 1. Stop iterating if the element is found > 2. Return the transformed element How about, transforming and then selecting? paths.map{|path| File.join(path, filename)}.select{|name| File.exist?(path)} (Untested) -- Anurag Priyam http://about.me/yeban/