From: Robert Klemme Date: 2007-09-20T05:55:03+09:00 Subject: Re: special Array method about Unix pathes On 19.09.2007 21:26, Une B�vue wrote: > Robert Klemme wrote: >> I can think of several approaches to solve this: >> >> 1. order the array and do a second iteration where each item is >> checked against the last seen prefix; the idea is that every string >> comes before the strings that contain it as prefix. > > fine, the Array is allready ordered elsewhere, i thought putting sort! > in this method )) If it's sorted anyway that's probably the approach I'd take. >> 2. insert names into a tree and output only prefixes during a tree walk. > > 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. >> 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. :-) Kind regards robert