Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift: For-in loop non-inclusive upper on PlayGround

I have just started playing with Swift. When using a Playground, according to Apple's iBook the following should work:

var firstForLoop = 0;

for i in 1..3 {
    firstForLoop += i;
}

However, the interpreter is complaining: "Use of unresolved identifier '..'" I have tried:

var firstForLoop = 0;

for i in 1...3 {
    firstForLoop += i;
}

and it works just fine (including the upper value in the loop). Has Apple removed the .. option from Swift's grammar?

like image 428
archipestre Avatar asked Sep 05 '25 03:09

archipestre


1 Answers

.. is now ..<.

You're probably using an old version of the book.

like image 143
Aaron Brager Avatar answered Sep 08 '25 00:09

Aaron Brager