for (index
, 아이템이름
) in 배열이름
.enumerated(){
code
}
let myFriendsArray : [String] = ["a", "b", "c", "d"]
var friendsWithIndex : [String] = []
//index없는 Foreach
myFriendsArray.Foreach{ aFriend in
print(aFriend)
}
for (index, aFriend) in myFriendsArray.enumerated(){
print("index: \(index), item: \(aFriend)")
friendsWithIndex.append("\(index).번 \(aFriend)")
}