How to use enumerated on string array to get the indexes and values in Swift

1 Answer

0 votes
var arr = ["swift", "c++", "java", "php"]

for (index, value) in arr.enumerated() {
    print("\(index) = \(value)")
}

 
 
/*
run:
 
0 = swift
1 = c++
2 = java
3 = php

*/

 



answered Sep 1, 2020 by avibootz
...