April 2017
Intermediate to advanced
316 pages
9h 33m
English
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 numbers = [3, 5, 9, 10] 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)].
Read now
Unlock full access