From: unbewusst.sein@... (=?ISO-8859-1?Q?Une_B=E9v?= =?ISO-8859-1?Q?ue?=) Date: 2007-09-20T14:45:08+09:00 Subject: Re: special Array method about Unix pathes Robert Klemme wrote: > > ok, i see what you mean, may be better not to do that when output rather > > than when building the three having a means to compare three deepness. > > I am not sure what you mean here. You have to build the tree first > before you can decide which branches you can omit. With "output" I did > not necessarily mean output to screen, but rather output from the > method. Maybe I should have chosen a different wording. I am sorry if > that caused confusion. i've found a simpler approach, in fact, this list of pathes is entered by the user using a File/folder chooser window, then instead of walking a three or something else, xhen the user enter a new path right now i check only if this path is allready taken into account by : files.each { |f| f_to_s = f.to_s @forbiddenList << f_to_s unless @forbiddenList.include_path?( f_to_s ) } with : files the File(s)/Folder(s) entered by the user ; f.to_s converting NSString to Ruby String (NS stands for NextStep) ; Array#include_path?( a_path ) being : class Array def include_path?(path) self.any? { | x | a_path.rindex( x, 0 ) } end end the only thing i dislike is in that pathes have nothing to do with Array,i must rexrite this part. > >> B�vue, the only issue I see with your method naming is that in Ruby > >> methods typically use under_scores and not CamelCase as in Java. > > > > Yes i've corrected that, it's an habit coming from java, as the getter > > "getContainers!"... > > Different languages, different conventions. :-) yes right, here i'm embarassed because my code isn't "pure" Ruby, it's RubyCocoa (a bridge between Cocoa/ObjC on Mac OS X) and in RubyCocoa the Cocoa methods like : NSOpenPanel#beginSheetForDirectory:file:types:modalForWindow:modalDelega te:didEndSelector:contextInfo: are translated, on the Ruby side, in : beginSheetForDirectory_file_types_modalForWindow_modalDelegate_didEndSel ector:contextInfo( ... ) then "_" replaces ":" and still camelized... -- Une B�vue