adjacentPairs

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

AdjacentPairs.swift:61
func adjacentPairs() -> AdjacentPairsCollection<Self>

In an AdjacentPairsCollection, 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...5).adjacentPairs() {
    print(pair)
}
// Prints "(1, 2)"
// Prints "(2, 3)"
// Prints "(3, 4)"
// Prints "(4, 5)"

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