Hi guys,
C-style for loops have been deprecated in Swift, but I can't find a replacement for how to do something like this:
The only way I can currently get it working is something like:
But I don't feel like using the modulo operator is the correct approach. Can someone more knowledgable than me in Swift explain how we should handle incrementing by something other than 1? I couldn't find anything in Apples docs or on Stack Overflow. Thanks.
C-style for loops have been deprecated in Swift, but I can't find a replacement for how to do something like this:
Code:
for i = 0; i < 100; i+=2 {
//Do stuff here
}
The only way I can currently get it working is something like:
Code:
for case let in 0...100 where n % 2 == 0
But I don't feel like using the modulo operator is the correct approach. Can someone more knowledgable than me in Swift explain how we should handle incrementing by something other than 1? I couldn't find anything in Apples docs or on Stack Overflow. Thanks.