func zip(_:_:)(_ sequence1: Sequence1, _ sequence2: Sequence2) -> Zip2Sequence<Sequence1, Sequence2>

Creates a sequence of pairs built out of two underlying sequences.

In the Zip2Sequence instance returned by this function, the elements of the ith pair are the ith elements of each underlying sequence. The following example uses the zip(_:_:) function to iterate over an array of strings and a countable range at the same time:

let words = ["one", "two", "three", "four"]
let numbers = 1...4

for (word, number) in zip(words, numbers) {
    print("\(word): \(number)")
// Prints "one: 1"
// Prints "two: 2
// Prints "three: 3"
// Prints "four: 4"

If the two sequences passed to zip(_:_:) are different lengths, the resulting sequence is the same length as the shorter sequence. In this example, the resulting array is the same length as words:

let naturalNumbers = 1...Int.max
let zipped = Array(zip(words, naturalNumbers))
// zipped == [("one", 1), ("two", 2), ("three", 3), ("four", 4)]