cycled

Returns a sequence that repeats the elements of this collection forever.

Cycle.swift:197
func cycled() -> CycledSequence<Self>

Returns

A sequence that repeats the elements of this collection forever.

Use the cycled() method to repeat the elements of a sequence or collection forever. You can combine cycled() with another, finite sequence to iterate over the two together.

for (evenOrOdd, number) in zip(["even", "odd"].cycled(), 0..<10) {
    print("\(number) is \(evenOrOdd)")
}
// 0 is even
// 1 is odd
// 2 is even
// 3 is odd
// ...
// 9 is odd