Sequence drop(while:) Seemingly Does Nothing

Viewed 1657

The Swift Standard Library asserts that:

drop(while:)

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

By using the function signature:

func drop(while predicate: (Self.Element) throws -> Bool) rethrows -> Self.SubSequence

Where predicate is described as:

A closure that takes an element of the sequence as its argument and returns a Boolean value indicating whether the element is a match.

My problem is that, under that description the following behavior shouldn't occur:

let test = (0...3).drop { $0 > 1 }
test.contains(0) // true
test.contains(3) // true
2 Answers
Related