Mastering macOS Programming
上QQ阅读APP看书,第一时间看更新

Saying goodbye to i++

So, how do we execute loops in an expressive and concise way without our trusted old i++ syntax? Well, Swift has a few options here, depending on exactly what you want to accomplish:

  • for loops iterate over ranges and collections
  • while loops run until a condition is no longer met