Returns a new set containing the elements of the set that satisfy the given predicate.
SDK
- Xcode 10.0+
Framework
- Swift Standard Library
Declaration
Parameters
isIncluded
A closure that takes an element as its argument and returns a Boolean value indicating whether the element should be included in the returned set.
Return Value
A set of the elements that is
allows.
Discussion
In this example, filter(_:)
is used to include only names shorter than five characters.