From: unbewusst.sein@... (=?ISO-8859-1?Q?Une_B=E9v?= =?ISO-8859-1?Q?ue?=) Date: 2007-09-20T04:30:12+09:00 Subject: Re: special Array method about Unix pathes Stefano Crocco wrote: > > This is my alternative solution: > > def select_toplevel_paths arg > a = arg.dup.sort_by{|i| i.size} > a.inject([]) do |res, i| > res.any?{|j| i.index(j) == 0 } ? res : (res << i) > end > end clever solution, thanks a lot ! however with the following (part of a yaml file) : forbiddenList: - /Volumes/EMTEC KEY/emtec_dl - /Volumes/EMTEC KEY/emtec_dl/v233r001/Setup.exe - /Volumes/U3 System - /Volumes/U3 System/Launchpad.zip your select_toplevel_paths don't remove /Volumes/EMTEC KEY/emtec_dl/v233r001/Setup.exe and /Volumes/U3 System/Launchpad.zip > > It doesn't change the contents of the array and it's not a method of class > Array, because, in my opinion, it's a too specialized method to be put in a > core class. U're right, i was embarassed with that point. > Regarding your code, I'd say names are correct, as far as English is > concerned. I'd like to give you a copule of suggestions: > * use underscores instead of camel-case (include_path? instead of includePath, > for example), because it's the more common style in the ruby community > * use start_with? instead of starts_with?. In the ruby standard library, there > are several cases in which both methods exist, with the ones ending in s being > obsolete (for example, File.exists? and File.exist?) For consistency, I think > it's better to follow the same convention. OK, done ! -- Une B�vue