prefix(while:)
Returns a subsequence containing the initial elements until predicate returns false and skipping the remaining elements.
Declaration
func prefix(while predicate: (Self.Element) throws -> Bool) rethrows -> Self.SubSequenceParameters
- predicate:
A 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.