- Swift Functional Programming(Second Edition)
- Dr. Fatih Nayebi
- 49字
- 2021-07-02 23:54:27
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 }