On Sun, 6 Jan 2008, scooterm / hotmail.com wrote:

> %w{ ant bear cat}.all? {|word| word.length >= 3}   #=> true
> %w{ ant bear cat}.any? {|word| word.length >= 3}   #=> true
>
> Both of these return true or false as expected. The question is
> is there an equivalent method that returns the original enum object
> itself (instead of just "true") if the test is satisfied? And nil or
> false
> if otherwise?
>
> I know code for this can be easily written, but the reason for the
> question is a matter of style; because it would be
> really nice not to have to specify the enum object more than one
> time if the test is satisfied.
>
> For example, in simple english, the "any" test would be: "If any item
> passes the test, then return all of the items".

%w{ant bear cat}.select{|word| word.length >= 3}

Aditya