April 2017
Intermediate to advanced
316 pages
9h 33m
English
stride functions enable us to iterate through ranges with a step other than one. There are two stride functions: the stride to function, which iterates over exclusive ranges, and stride through, which iterates over inclusive ranges. Consider the following example:
let fourToTwo = Array(stride(from: 4, to: 1, by: -1)) // [4, 3, 2] let fourToOne = Array(stride(from:4, through: 1, by: -1)) // [4, 3, 2, 1]
Read now
Unlock full access