Selecting Sequences and Strides
Swift offers several built-in approaches to numeric progressions. These include ranges, stride functions, and sequence functions. Select your solution based on the progression you’ll produce. The latest versions of Swift provide excellent tools for establishing sequences.
In particular, Swift has eliminated many of the issues that previously detracted from floating-point strides. Strides no longer introduce cumulative errors during their execution the way traditional C for loops did. When choosing between stride and sequence, base your selection on utility, not accuracy concerns.
Prefixing
Swift 3.1 adds more flexibility and power by introducing prefix(while:) and drop(while:) as native operations on sequences. ...
Get Swift Style now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.