Swift For循環普通取得Value寫法

for value in testList {
    print("\(value)")
}

Swift For循環取得Index,Value寫法

var testList = [String]()
testList.append("測試1")
testList.append("測試2")

for (index,value) in testList.enumerated() {
    print("\(index): \(value)")
}

Categorized in:

Tagged in:

, , ,