The zip
function is provided by the Swift standard library and creates a sequence of pairs built out of two underlying sequences, where the elements of the ith pair are the ith elements of each underlying sequence.
For instance, in the following example, zip
takes two Arrays
and creates a pair of these two arrays:
let alphabeticNumbers = ["Three", "Five", "Nine", "Ten"] let zipped = zip(alphabeticNumbers, numbers).map { $0 }
The value for zipped
will be [("Three", 3), ("Five", 5), ("Nine", 9), ("Ten", 10)]
.