an attempt to create a for loop in swift leads to two errors:

expected

Braced block of statements is an unused closure

code to play:

for i in 0..< numberOfEuropeCities { } 

Closed due to the fact that off-topic participants Streletz , aleksandr barakin , Pavel Mayorov , Nick Volynkin 23 May '16 at 6:18 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reasons:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - Pavel Mayorov, Nick Volynkin
  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Streletz, aleksandr barakin
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    let's re-open something. The question is quite a matter of itself - swift has some oddities with syntax enforcing. I think this question may come in handy. - Max Mikheyenko
  • @MaxMikheyenko, you must first bring the question to a normal form. Now the question, in my opinion, is useless for those who are faced with a similar problem: because they simply will not find it by search engines. that's why I voted for the closure. - aleksandr barakin
  • @alexanderbarakin tried to fix - Max Mikheyenko

2 answers 2

there is either no space

 for i in 0..<numberOfEuropeCities { 

either be on both sides

 for i in 0 ..< numberOfEuropeCities { 

    Problem solved!
    My error disappeared when I added a space:

     for i in 0 ..< numberOfEuropeCities 
    • Please do not reply with the phrase "thank you". When your reputation reaches the required level, you will be able to vote for questions and answers that you find useful. - From the queue of checks - torokhkun
    • 3
      @totorro please be careful! This is not the phrase "thank you", this is the author's decision (quite normal practice)! - Pavel Mayorov
    • @PavelMayorov difference in the gap between zero and dots? - Nick Volynkin
    • one
      @NickVolynkin is not familiar with this language - but, judging by the answer, yes - Pavel Mayorov