[Solved] Loop over a small array repeatedly to get a larger number of items [duplicate]


The modulo operator % is going to be your friend here.
I don’t have a compiler in front of me and always mess up the range syntax but the below should illustrate the idea…

for i in 0..<100 {
    let theItem = array[i % array.count]
}

solved Loop over a small array repeatedly to get a larger number of items [duplicate]