From: David Alan Black Date: 2002-04-21T23:44:46+09:00 Subject: Re: A few ideas/suggestions Hi -- On Sun, 21 Apr 2002, Tobias Reif wrote: > Michael Brailsford wrote: > > > > Well, first I think that it makes a lot of sense if Dir#[] accepted a > > Regexp as well a String like it currently does. String#[] already > > implements something similar. I think that Dir[/.*\.rb/] makes a lot of > > sense. > > > I think so too. I don't think the fact that String#[] can take a regex argument is a good regex argument. Hash#[] can take anything, as can Hash.[] (the class method, which might be a better parallel since the Dir one is really Dir.[]). That doesn't mean that other #[]'s should be expected or required to emulate Hash's []'s. There's no universal, underlying []. Personally I'm not convinced of the practical usefulness of Dir[aRegexp] (as last night's #ruby-lang logs will verify :-) though that doesn't mean others wouldn't find it useful. In more practical terms, I'm not sure what array of strings (filenames) would be tested against the regex for inclusion. Is it always Dir["*"]? Or Dir["."].entries? For example: Dir[/.*\.rb/] would be equivalent, I guess, to: some_array.grep(/.*\.rb/) But what is that some_array? David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav