[swift-users] Tuple Member Extraction in Closure Parameters

Krzysztof Siejkowski krzysztof at siejkowski.net
Thu May 5 09:19:08 CDT 2016


A workaround is to declare two local variables:

let e = zip(a,b).reduce(0) { acc, tuple in
  let value1 = tuple.0
  let value2 = tuple.1
  return acc + value1 + value2
}
You can also get away with one assignment:

let ok = zip(a,b).reduce(0) { acc, tuple in
    let (value1, value2) = tuple
    return acc + value1 + value2
}

Best,
Krzysztof
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160505/c64eb70b/attachment.html>


More information about the swift-users mailing list