If you want to include 0*constant
:
let arr = Array(0..<size).map { $0 * constant }
If you don’t want to (i.e., start at 1*constant
):
let arr = Array(1..<size).map { $0 * constant }
If you don’t want to multiply by a constant (or the constant is 1
):
let arr = Array(0..<size)
solved pick an element in a dynamic array without repetition in Swift