Returns an array containing, in order, the elements of the sequence that satisfy the given predicate.
- macOS 10.14+
- Xcode 10.0+
- Create ML
A closure that takes an element of the sequence as its argument and returns a Boolean value indicating whether the element should be included in the returned array.
An array of the elements that
In this example,
filter(_:) is used to include only names shorter than five characters.
Complexity: O(n), where n is the length of the sequence.