I'm trying to iterate an array with an index in Swift 3 but keep getting
Expression type '[Int]' is ambiguous without more context
this is reproducible with the following example in a playground:
var a = [Int]()
a.append(1)
a.append(2)
// Gives above error
for (index, value) in a {
print("\(index): \(value)")
}
I'm not sure what context it is asking for.
in agives you one value (i.e. 1, or 2), not a tuple with both an index and a value.for (index,value) in a, whenais an array, is just silly talk.