On 2006-02-09, Kelly Dwight Felkins <railsinator / gmail.com> wrote:

> Is there a way for collect to return fewer items than the enumerable
> the collect is running on?

Strictly speaking, no (AFAIK), but it's easy to fake it.  Use
Array#collect with a block that returns nil when you don't want an
element, then Array#compact the result.

Similarly, to get the effect of a block returning multiple values to
Array#collect, just have the block return an Array and then
Array#flatten the result.

Cheers, 

Jeremy Henty