Hi -- On Thu, 23 Aug 2007, Giles Bowkett wrote: > So I've got this file-checking script: > > def check > ok = true > for_every_app do |app,app_info| Do you mean for there to be an .each in there? > ok = File.exists?(app_info[:root]) > end > ok > end > > And it has a bug, which is that if it evaluates a good file after a > bad file, it'll return true for the whole list. > > So here's my suggested change: > > def check > ok = true > for_every_app.values.each do |app_info| > ok = File.exists?(app_info[:root]) if ok > end > ok > end > > Because if we have one false value, then the whole test is > unnecessary. It's basically like a short-circuit operator. > > But I think there's a better way to do it with map. > > Something like > > File.exists?(for_every_app.values.map{|x| x} > > I think I'm way off, though. How do I get that right? You could do: def check for_every_app.all? {|app,info| File.exists?(info[:root])} end David -- * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.com)