I can easily destroy a tuple of a tuple:
let tt = (2, (3, 4)) let (a, (b, c)) = tt b
I would like to do the same when declaring closure, for example, I thought I could write:
[tt].map { (a, (b, c)) in
Xcode complains about "An unnamed parameter must be written with an empty name."
The only way to make it βworkβ was:
[tt].map { (a, tuple: (b: Int, c: Int)) in
This has two drawbacks that I would like to avoid:
- I need to use
tuple.b instead of b - I need to specify types
b and c
By the way, my use case is I want to do reduce with an index, so I'm trying to use array.enumerate().reduce
source share