<分区>
var players = ["Donna", "Craig", "Brian", "Anna"]
let scores = [2, 2, 4, 5]
for (indexx, score) in scores.enumerate() {
for (index, player) in players.enumerate() {
if indexx != index {
continue
}
print("Player's Name: \(player) Score: \(score)")
}
}
我使用到目前为止所学的有关 for-in 循环和数组的知识制作了此方法。是否有更充分的方法来创建打印出玩家姓名和分数的 for-in 循环?
Player's Name: Donna Score: 2
Player's Name: Craig Score: 2
Player's Name: Brian Score: 4
Player's Name: Anna Score: 5