Articles, podcasts and news about Swift development, by John Sundell.

Using zip

Published on 16 Jan 2018
Basics article available: Map, FlatMap and CompactMap

Using the zip function in Swift you can easily combine two sequences. Super useful when using two sequences to do some work, since zip takes care of all the bounds-checking.

func render(titles: [String]) {
    for (label, text) in zip(titleLabels, titles) {
        label.text = text