Searching for: For Loop in Swift
For In Loop
Language: Swift

The for-in loop iterates through every element in a collection (array, set, or dictionary) without specifying size. It behaves like a for each in other languages. The C-style for loop is now deprecated in Swift. To emulate the C-style for loop, use a range as the collection.

While Loop
Language: Swift

The while loop executes a block of code while a boolean expression evaluates to true. It terminates as soon as the expression evaluates to false. The boolean expression is evaluated before each iteration.