Hello --

On Tue, 16 Oct 2001, Miles Egan wrote:

> >Try Array#select.
> >
> >irb(main):001:0> a = [1,2,3,4]
> >[1, 2, 3, 4]
> >irb(main):002:0> b = a.select { |i| i % 2 == 0 }
> >[2, 4]
> >
> >Jimmy
>
> Excellent.  Thanks for your help.  This isn't in the docs, so I missed it.

Hmmm.... it should be in the docs.  It's Enumerable#select, a synonym
for Enumerable#find_all.

Output from ri:

------------------------------------------------------ Enumerable#select
     enumObj.select {| obj | block }  -> anArray
------------------------------------------------------------------------
     Synonym for Enumerable#find_all.


---------------------------------------------------- Enumerable#find_all
     enumObj.find_all {| obj | block }  -> anArray
------------------------------------------------------------------------
     Returns an array containing all elements of enumObj for which block
     is not false (see also Enumerable#reject).
        (1..10).find_all {|i|  i % 3 == 0 }   #=> [3, 6, 9]



David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav