Doubt with creation of For in Swift 3

0

I'm following an iOS course and the course shows for this way:

for var i = 1; i <= 10; i++ {

}

But I have an error message, has that changed? How could this be done in the new way?

  

error: CreatingLoop.playground: 6: 1: error: C-style for statement has been removed in Swift 3

    
asked by anonymous 12.05.2017 / 14:49

1 answer

0

Will print from 1 to 10

for i in 1 ... 10 {
    print(i)
}

Will print from 1 to 9

for i in 1 ..< 10 {
    print(i)
}
    
12.05.2017 / 19:45