Calls the given closure on each element in the sequence in the same order as a
- Xcode 8.0+
- Swift Standard Library
A closure that takes an element of the sequence as a parameter.
The two loops in the following example produce the same output:
for method is distinct from a
in loop in two important ways:
You cannot use a
continuestatement to exit the current call of the
bodyclosure or skip subsequent calls.
returnstatement in the
bodyclosure will exit only from the current call to
body, not from any outer scope, and won’t skip subsequent calls.