Looping

A loop is a type of operation which allows us to perform computation a certain number of times. For example, given a collection of items we could call a method on the first item and iterate until the method has been called on each item.

Usually, a loop has a condition which prevents it from continuing indefinitely however it is possible to create a loop that never stops i.e. an infinite loop.

Programming languages have various forms of syntax for declaring a loop which may slightly alter how the iteration takes place.

Sway has the following loops: