The filter function

The filter function is a higher-order function that takes a function that, given an element in the array, returns Bool, indicating whether the element should be included in the resulting array. Consider the following example:

let evenNumbers = numbers.filter { $0 % 2 == 0 }