From: Nobuyoshi Nakada Date: 2007-09-20T03:43:00+09:00 Subject: Re: special Array method about Unix pathes Hi, At Thu, 20 Sep 2007 03:24:58 +0900, Stefano Crocco wrote in [ruby-talk:269890]: > 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) i.rindex(j, 0) is faster than i.index(j) == 0 when j matches in the middle. > * 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. And ruby 1.9 has String#start_with? already in fact. -- Nobu Nakada