Skip to main content

Array.filter

filterfilter

Group: Selections

Documentation

Selects all elements of this array which satisfy a condition.

Arguments

  • filter: The filter to apply to the array. It can either be an instance of Filter_Condition or a predicate taking a value and returning a boolean value indicating whether the corresponding element should be kept or not.

Examples

Selecting all elements that are greater than 3.

      [1, 2, 3, 4, 5].to_array.filter (> 3)
[1, 2, 3, 4, 5].to_array.filter (..Greater than=3)