I've reached a point in an application where I need to initialize some coordinates to an array and I wound up using nested for-in loops to accomplish the task.
Is there is a better way to accomplish this?
class Coord {
let xVal : Int
let yVal : Int
init(x: Int, y: Int) {
xVal = x
yVal = y
}
}
var coord = [Coord]()
for xVal in 0...20 {
for yVal in 0...20 {
coord.append(Coord(x: xVal, y: yVal))
}
}