Hi --

On Sat, 21 Sep 2002, Bruce Williams wrote:

> On Friday 20 September 2002 11:55 am, dblack / candle.superlink.net wrote:
> >
> > I would use #select, which filters based on a condition contained
> > in a code block:
> >
> >   a = ["aaa","abb","bbb","acc","bcc","ccc"]
> >   puts a.select {|e| /(a|c)cc/.match(e)}
> >
> >   =>
> >     acc
> >     ccc
> >
> >
> > David
>
> I think I'd use Enumerable#grep in this case:
>
> irb(main):001:0> a = ["aaa","abb","bbb","acc","bcc","ccc"]
>   ["aaa", "abb", "bbb", "acc", "bcc", "ccc"]
> irb(main):002:0> a.grep /(a|c)cc/
>   ["acc", "ccc"]

I *always* forget that one :-)


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