When using map() with enumerate(), Swift will decompose the enumerate tuple:
map(enumerate([1,2,3])) { (index, element) in
index + element
}
However, this does not appear to work alongside an additional closure parameter (e.g., with reduce()):
reduce(enumerate([1,2,3]), 0) { (accum, (index, element)) in
accum + index + element
}
This fails with error: use of undeclared type 'index'
.
Am I missing something simple, or does Swift simply not allow decomposing a tuple alongside an additional parameter? I have tried this in 1.1 and 1.2. (For now, I am using the shorthand argument names.)