Excerpts from Jonas Pfenniger (zimbatm)'s message of Sat Jan 08 16:05:05 -0800 2011:
> 2011/1/8 Anurag Priyam <anurag08priyam / gmail.com>:
> >> paths.map{|path| File.join(path, filename)}.select{|name| File.exist?(path)}
> >
> > Of course, I meant to use name, instead of path in the last section. So:
> >
> > file = paths.map{|path| File.join(path, filename)}.select{|name|
> > File.exist?(name)}
> 
> Yes, if you replace #select by #find, then it is correct, you'll get
> the same result as my algorithm. But if the result is in the first
> entry, then all subsequent paths are unnecessarily joined.
> 
> Another version of the algorithm would be:
> 
> path = paths.find{|p| File.exist?(File.join(p, filename)) }
> if path
>   abs_path = File.join(path, filename)
> end

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

-- 
med vänlig hälsning
David J. Hamilton