adjacentPairs

Returns a sequence of overlapping adjacent pairs of the elements of this sequence.

AdjacentPairs.swift:34
func adjacentPairs() -> AdjacentPairsSequence<Self>

In the AdjacentPairsSequence returned by this method, the elements of the ith pair are the ith and *(i+1)*th elements of the underlying sequence. The following example uses the adjacentPairs() method to iterate over adjacent pairs of integers:

for pair in (1...).prefix(5).adjacentPairs() {
    print(pair)
}
// Prints "(1, 2)"
// Prints "(2, 3)"
// Prints "(3, 4)"
// Prints "(4, 5)"

The resulting sequence is empty when called on an empty or single-element sequence.