Returns a subsequence containing the initial elements until predicate returns false and skipping the remaining elements.
SDK
- Xcode 9.0+
Framework
- Swift Standard Library
Declaration
Parameters
predicateA closure that takes an element of the sequence as its argument and returns
trueif the element should be included orfalseif it should be excluded. Once the predicate returnsfalseit will not be called again.
Discussion
Complexity: O(n), where n is the length of the collection.