0

With the recent availability of Swift 2.2, we have confirmation that the for-loop (in its traditional form) will be phased out of Swift, most likely in Swift 3.

for(var i = 0; i < 5; i++)

will be replaced with the for-in:

for i in 0 ..< 5

I have read that Swift aims to maintain a level of interoperability with C (as stated in the Swift 2.1 release docs).

From a language-design and planning standpoint, why would this be the best option, as the traditional for-loop is one of the most used types of loops and it has been included in the language from the beginning?

Jake Chasan
  • 6,290
  • 9
  • 44
  • 90
  • 3
    There's the full explanation from GitHub: https://github.com/apple/swift-evolution/blob/master/proposals/0007-remove-c-style-for-loops.md TLDR: it's used mostly by beginners. Advanced users vastly preferred the Swifty loops – Code Different Mar 26 '16 at 20:50
  • As I understand Apple team does want to keep everything as concise as possible. The normal swift way of doing for loop is shorter and easier than the standart C-like way. Lesser evil is to keep only one way of doing that (otherwise you end up with something like class vs static - a lot of people do not understand the difference). Maybe it's not a good example, because class vs static HAS the difference, meanwhile for loop notation did the same thing, but anyway :) – invisible_hand Mar 26 '16 at 20:51
  • Believe me you want miss it – Leo Dabus Mar 26 '16 at 21:32

0 Answers0