StructureSwift

Zip2Sequence

A sequence of pairs built out of two underlying sequences.

@frozen struct Zip2Sequence<Sequence1, Sequence2> where Sequence1 : Sequence, Sequence2 : Sequence

Overview

In a Zip2Sequence instance, the elements of the ith pair are the ith elements of each underlying sequence. To create a Zip2Sequence instance, use the zip(_:_:) function.

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"

Members

Typealiases

Instance Properties

Instance Methods

Structures

Conforms To

Removed Members

Typealiases