Swift For Stride Loop Decrement

I’ve been learning some Swift on Plurasight. We were going over the ‘unique’ ways Swift approaches For Loops. I did the exercises in Fire and it appears that a decrementing For Stride Loop will not return any values to the console or debugger. Thanks for taking a look. :nerd_face:

import Foundation

print("The magic happens here.")

for number in stride(from: 100, to: 0, by: -5) {   

Since we’re on the same topic, it appears that Elements does not have an option for a for stride through loop.


I’ll have a look at both fo these…

looks like this was commented out top work around a compiler bug/limitation; I’ll check the status on that and see if I can add it back. (bugs://75284: Silver: can’t overload global func on parameter names)

Update: Fixed, except for the Double version of stride on Toffee, that one still fails, and I have reopened 75284 to solve that)

fixed; these were hardcoded to only accept positive by values; it seems that was as designed originally, and Apple has since their version.

Both of these fixes will be in today’s build, .2627; thanx for reporting!

1 Like

On a positive note, I’m about 2/3rd’s of the way through the Swift tutorial and everything else has worked as expected in Fire (functions, arrays, etc…) :nerd_face:

I am very happy to hear that! :raised_hands:t3:

Just a quick note that both the decrement and for stride through loops work as expected now with the latest build. Cheers :beers:

1 Like