我对坐标和坐标。当我不实例化实例坐标时,列和行accsss如何?如果是for循环intatientiate坐标,则在Allcoordinate或World时如何实例化。AllPossibleCoordinate不是类型?(世界周围没有督导教义。
let allCoordinates = world.allPossibleCoordinates
var blockSet: [Coordinate] = []
//#-editable-code Tap to enter code
for coordinate in allCoordinates {
// Check for coordinates with a column > 5 OR a row < 4.
if coordinate.column > 2 && coordinate.row < 5 {
// Append coordinate to blockSet.
}
}
在Swift
中,for in
循环的工作方式与其他语言中的for
循环的作用有所不同。for in
循环大步在一个范围内(我假设Allcoordinate是可行的(。在提供的示例中,如果变量Allcoordinates是一个可行的范围,则循环将通过该范围内的每个项目,将每个值分配给coordinate
每个迭代。有关更多信息,请查看Apple的文档