--1926193751-1852195539-11878160985922 Content-Type: MULTIPART/MIXED; BOUNDARY="1926193751-1852195539-1187816098=:25922" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --1926193751-1852195539-11878160985922 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Hi -- On Thu, 23 Aug 2007, Stefano Crocco wrote: > Alle mercoled22 agosto 2007, Erik Veenstra ha scritto: >> Faster, because it breaks the loop as soon as possible, and >> less LOC: >> >> def check >> for_every_app.values.find do |app_info| >> not File.exists?(app_info[:root]) >> end ? false : true >> end >> >> You may want to skip the "? false : true" part, but that breaks >> the encapsulation. >> >> gegroet, >> Erik V. - http://www.erikveen.dds.nl/ > > This is shorter, and breaks as soon as a non-existing file is found > > def check > !for_every_app.values.any?{|f| !File.exist?(f)} > end You can save yourself the double negative: for_every_app.values.all?{|f| File.exist?(f)} And even save the creation of an intermediate array of values: for_every_app.all?{|a,b| File.exist?(b)} But I repeat myself :-) (See my earlier post.) 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) --1926193751-1852195539-11878160985922-- --1926193751-1852195539-11878160985922--