partition :: Enumerable

partition([iterator = Prototype.K]) -> [TrueArray, FalseArray] Partitions the elements in two groups: those regarded as true, and those considered false. By default, regular JavaScript boolean equivalence is used, but an iterator can be provided, that computes a boolean representation of the elements.

This is a preferred solution to using both findAll/select and reject: it only loops through the elements once!

Examples

['hello', null, 42, false, true, , 17].partition()

// -> [['hello', 42, true, 17], [null, false, undefined]]

$R(1, 10).partition(function(n) {

return 0 == n % 2;

})

// -> [[2, 4, 6, 8, 10], [1, 3, 5, 7, 9]]

Prototype API 1.5.0 - prototypejs.org