I really like the feel of 'pick' with arrays.

What about a 'pick_as' option for the hash?

It would be nice though - with hashes - to say whether or not I'm 'picking'
responses based on the key or the value...

h = {"one" => 1, "two" => 2, "different" => 2}
integerResponse = h.pick_as_key("two")    # => 2
arrayResponse = h.pick_as_value(2)    # => "two", "different"

If there was some way to 'refine' how the selection was made, the 'pick'
method could more easily extend to other structures... objects (select
[methods | properties | parent | child] ) ?

Looking at it again - maybe
'pick'
'pickKey'
'pickValue'
'pickParent'
'pickMethod'
.... and then apply regExp to the 'pick' allowing me even greater freedom
and selection...

... but that could also get out of hand easier.

Synonyms for 'select'::

chosen, elect, exclusive, pick, picked, selected, culled, screened, weeded
(out), winnowed (out); favored, preferred; best, elite, choice, dainty,
delicate, elegant, exquisite, rare, recherch?, superior

... out of those... pick still looks good...

My vote's on 'pick'. Good call.

-Richard Lyman


----- Original Message -----
From: <dblack / candle.superlink.net>
To: "ruby-talk ML" <ruby-talk / ruby-lang.org>
Sent: Saturday, September 21, 2002 8:47 AM
Subject: Re: select and select


> Hi --
>
> On Sat, 21 Sep 2002, Yukihiro Matsumoto wrote:
>
> > Hi,
> >
> > In message "Re: select and select"
> >     on 02/09/20, Joel VanderWerf <vjoel / PATH.Berkeley.EDU> writes:
> >
> > |What about these?
> > |
> > |   at_indices   (too long, ugly)
> > |
> > |   sample       (not very clear)
> > |
> > |   pick         (too close to select)
> >
> > I like "pick".  How do others feel (especially English speaking ones)?
>
> Just so I can see it in action:
>
>   ar = %w{ one two three four }
>
>   ar.pick(0,3)                  # => ["one", "four"]
>   ar.select {|e| e.size == 3}   # => ["one", "two"]
>   ar.pick()                     # => [] (or ArgumentError?)
>
>   h = {"one" => 1, "two" => 2}
>   h.pick("one", "two")          # => [1,2]
>
>
> I agree with Joel that it's close in meaning to select, but for some
> reason it doesn't bother me.  I find it pretty clear, possibly a
> little better suited to arrays than hashes but still OK.
>
> Just to throw in something else, I was thinking about "find_at",
> which I like as a complement to #find_all:
>
>   ar.find_all { condition }
>   ar.find_at(1,3)
>
>
> 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
>