findAll :: Enumerable

findAll(iterator) -> Array Returns all the elements for which the iterator returned true. Aliased as select.

This is a sort of all-purpose version of grep (which is specific to String representations of the values). findAll lets you define your predicate for the elements, providing maximum flexibility.

Examples

$R(1, 10).findAll(function(n) { return 0 == n % 2; })

// -> [2, 4, 6, 8, 10]

[ 'hello', 'world', 'this', 'is', 'nice'].findAll(function(s) {

return s.length >= 5;

})

// -> ['hello', 'world']

See also

The reject method is the opposite of this one. If you need to split elements in two groups based upon a predicate, look at partition.

Enumerable: reject | partition

Prototype API 1.5.0 - prototypejs.org