I tried to skip the dictionary:
let someDict = [...]
for (index, (a, b)) in someDict.enumerated() {
}
This shows me an error:
cannot express tuple conversion '(offset: Int, element: (key: String, value: String))' to '(Int, (String, String))'
This is really weird. Because if we compare the required tuple:
(offset: Int, element: (key: String, value: String))
with a tuple type in a for loop:
(Int, (String, String))
They are compatible!
Why is this happening?
Note, I understand that dictionaries do not have a specific order, so knowing the KVP index is not very useful. But I still want to know why this is not working.
source
share