O'Reilly logo

Swift Functional Programming - Second Edition by Dr. Fatih Nayebi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The stride functions

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] 

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required