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