cycled(times:)

Returns a sequence that repeats the elements of this collection the specified number of times.

Cycle.swift:219
func cycled(times: Int) -> CycledTimesCollection<Self>

Parameters

times

The number of times to repeat this sequence. times must be zero or greater.

Returns

A sequence that repeats the elements of this sequence times times.

Passing 1 as times results in this collection’s elements being provided a single time; passing 0 results in an empty sequence. The print(_:) function in this example is never called:

for x in [1, 2, 3].cycled(times: 0) {
    print(x)
}