Swift 4 Loops
Loop is used when you want to execute a block of codes several times. It executes the statement sequentially. It means it executes the first statement within the function first, followed by second and third and so on.
Swift 4 provides several control structures to allow more complicated execution paths.
In Swift 4 programming language, loops are used to execute a statement or a group of statements when you need to execute them multiple times.
Every programming language has some general form of loop statement.
A general structure of loop statement
Loops used in Swift 4 programming language
A list of most used loops in Swift 4 programming language:
for-in loop: The for-in loop is used to execute a set of statements for each item in a range, selection, collection etc.
while loop: The while loop is used to repeat a statement or a set of statements when the given condition is true. It checks the conditions before executing the loop body.
repeat... while loop: It is same as the while loop but it checks the condition at the end of the loop body.
Next Topicfor-in loop