所以我试图查看我的循环运行多少次测试打印语句。我的外循环运行5次,这就是我想要的。内循环只运行23次而不是25次?我错过了什么?
func currentLocation() -> GameLocation {
for yValue in 0...4{
for xValue in 0...4{
let tempX = gameGrid[yValue].locations[xValue].x + 2
print("x")
let tempY = gameGrid[yValue].locations[xValue].y + 2
if currentRowIndex == tempX && currentLocationIndex == tempY {
return GameLocation(x: gameGrid[yValue].locations[xValue].x, y: gameGrid[yValue].locations[xValue].y, allowedDirections: gameGrid[yValue].locations[xValue].allowedDirections, event: gameGrid[xValue].locations[xValue].event) }
}
}
return GameLocation(x: 0, y: 0, allowedDirections: [], event: nil)
}