From: dblack@... Date: 2002-09-20T02:33:43+09:00 Subject: Re: select and select Hi -- On Fri, 20 Sep 2002, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: select and select" > on 02/09/20, dblack@candle.superlink.net writes: > > |Maybe it would seem a better fit if the two were combined? > > | arr.select {|s| s == "c"} # ["c"] > | arr.select(0,2,4) # ["a", "c", "e"] > | arr.select(0,2,4) { |s| s == "c" } # ["c"] > > Hmm, from this combination, > > arr.select {|s| s == "c"} > > can be considered as > > arr.select() {|s| s == "c"} > > i.e. > > arr.select(*[]) {|s| s == "c"} # [] ??? > > Of course, current behavior has this too, but would combination > emphasize wierdness? Good question. I guess the arguments to select defaults to *(0...size), which might be kind of weird. Or one could say that the arguments to select are constraints on the selection, and that in the absence of such constraints, everything is selected. > |I think I would still like this better: > | > | arr.at(0,2,4).select { |s| s == "c" } > > I admit this is better in some aspect. > > Does "at" takes multiple placement make you feel natural? > And is this natural for Hashes? For Arrays I do like at(x,y,z). It seems natural to me. For Hashes, I don't think I usually refer to a value as being "at" a key... but it sounds sort of right. 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