From: unbewusst.sein@... (=?ISO-8859-1?Q?Une_B=E9v?= =?ISO-8859-1?Q?ue?=) Date: 2007-09-20T01:00:19+09:00 Subject: special Array method about Unix pathes here is the goal: i've an Array of Unix pathes : forbidden = ["/Volumes/U3 System", "/Volumes/EMTEC KEY/emtec_dl", "/Volumes/EMTEC KEY/emtec_dl/Win98SE new driver.exe", "/Volumes/EMTEC KEY/emtec_dl/v233r001" ] i want to forbid access to those pathes BUT since, for example, "/Volumes/EMTEC KEY/emtec_dl/Win98SE new driver.exe" � belongs � to the path (it's below this path) "/Volumes/EMTEC KEY/emtec_dl" it is unusefull to have it in the Array. in the case above i'd like to return : forbidden = ["/Volumes/U3 System", "/Volumes/EMTEC KEY/emtec_dl" ] what i've done : class Array def includePath?(path) self.each { | x | return true if path.startsWith?(x) } return false end def getContainers! self.delete_if { | x | ( self - [ x ] ).includePath?( x ) } end end class String def startsWith?(dir) self.index(dir) === 0 end end then forbidden.getContainers! gives me the expected result. what do you think about this solution ? could you propose a better one ? also, because english isn't my mother tongue, are my methods naming correct ? -- Une B�vue