Instance Method

drop(while:)

Returns a subsequence by skipping elements while predicate returns true and returning the remaining elements.

Declaration

func drop(while predicate: (Bound) throws -> Bool) rethrows -> Range<Bound>
Available when Bound conforms to Strideable and Bound.Stride conforms to SignedInteger.

Parameters

predicate

A closure that takes an element of the sequence as its argument and returns true if the element should be skipped or false if it should be included. Once the predicate returns false it will not be called again.

Discussion

Complexity: O(n), where n is the length of the collection.

See Also

Excluding Elements

func dropFirst(Int) -> Range<Bound>

Returns a subsequence containing all but the given number of initial elements.

func dropLast(Int) -> Range<Bound>

Returns a subsequence containing all but the specified number of final elements.

func popFirst() -> Bound?

Removes and returns the first element of the collection.

func popLast() -> Bound?

Removes and returns the last element of the collection.

func removeFirst() -> Bound

Removes and returns the first element of the collection.

func removeFirst(Int)

Removes the specified number of elements from the beginning of the collection.

func removeLast() -> Bound

Removes and returns the last element of the collection.

func removeLast(Int)

Removes the given number of elements from the end of the collection.