You could leverage flatMap
on Array:
Array(repeating: [1,2,3], count: 10).flatMap { $0 }
gives you [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]
.
The documentation for Array.flatMap
actually has pretty good documentation of what flatMap
does with Arrays (concatenation).
As the docs point out, you can also use
Array(Array(repeating: [1,2,3], count: 10).joined())
which is probably a better and more readable way of achieving what you're looking for.