c-style for loops are getting sacked in Swift 3 and it's a good idea to comply as soon as possible.
swift collection types actually provide a list of their indexes no matter of the index type so I say we should use those across tutorials and books. E.g:
not preferred:
for var i=0;i<items.count;i++ { ..items[i]... }
preferred:
for i in items.indices { ... items[i] ... }
@micpringle ?
馃憤
I'm for avoiding using C-style loops.
However, this will already generate a warning in Xcode 7.3 if you use them.
As we already don't allow warnings, does this really need to be explicitly included?
the new loop looks great
but for the loop of this type what should be done?
for var i=0;i
for .... in ?
@khalidmahmud
for i in 0.stride(to: items.count, by: 2) {
// items[i]
}
@yas375
thanks bro
Approved. Adding a section about compiler warnings being verboten. Also will change the current not preferred examples to use a while loop.
Apologies that there might be some noise here. I guess I am learning the github pull request workflow. :)
Most helpful comment
@khalidmahmud