I have a method that I'm using to create an array w/ n of a specific type of object in it:
func many(count: Int) -> [Cube] {
var cubes: [Cube] = []
for i in 0...count {
let cube = CubeFactory.single()
cubes.append(cube)
}
return cubes
}
This works but I'm sure there's a more swift like way to do this. Any one know how this can be refactored?
func many(count: Int) -> [Cube] { return [Cube](count: count, repeatedValue: Cube.single()) }