From: dblack@... Date: 2002-09-20T00:05:44+09:00 Subject: Re: select and select Hi -- On Thu, 19 Sep 2002, Yukihiro Matsumoto wrote: > Hi, > > In message "select and select" > on 02/09/19, dblack@candle.superlink.net writes: > > |I'd like to suggest (again, but the first time it was buried in > |another thread :-) that the new dual nature of "select" is kind of > |awkward, and I'm wondering whether it's been finalized. > > Not yet, until 1.8.0 comes out. (don't ask me when it will be.) > But considering the loooong thread we had without conclusion, it is > very hard to get a perfect name for the method. But I'm still open. Maybe it would seem a better fit if the two were combined? class Array alias :oldselect :select def select(*inds,&b) s = if inds.empty? then self else inds.map {|i| at(i)} end s = s.oldselect(&b) if b s end end arr = %w{ a b c d e } arr.select {|s| s == "c"} # ["c"] arr.select(0,2,4) # ["a", "c", "e"] arr.select(0,2,4) { |s| s == "c" } # ["c"] I think I would still like this better: arr.at(0,2,4).select { |s| s == "c" } David -- David Alan Black | Register for RubyConf 2002! home: dblack@candle.superlink.net | November 1-3 work: blackdav@shu.edu | Seattle, WA, USA Web: http://pirate.shu.edu/~blackdav | http://www.rubyconf.com