[swift-evolution] [Proposal][Discussion] Deprecate Tuple Shuffles

Adrian Zubarev adrian.zubarev at devandartist.com
Fri May 5 01:33:29 CDT 2017


I’m aware what a label is, I just had a small misunderstanding about nested destructuring. ;-)

Issue solved for me.

let (a, b /* inner tuple */) = tuple

let (_, (x, y)) = tuple
+1 I don’t mind this change at all.



-- 
Adrian Zubarev
Sent with Airmail

Am 5. Mai 2017 um 08:14:10, Xiaodi Wu (xiaodi.wu at gmail.com) schrieb:

On Fri, May 5, 2017 at 1:12 AM, Adrian Zubarev <adrian.zubarev at devandartist.com> wrote:
Oh pardon, on the first glance I didn’t realized the issue with that example.

Here is an updated example that would work:

let (first, second: (x, y)): (first: Int, second: (x: Int, y: Int)) = tuple
This should work right?

No, again, this would be banned. You are using a label (a thing that ends in a colon) inside a tuple pattern (a thing between parenthesis that comes after "let").
 
It’s assigning the inner tuple to second while also creating two additional constants from the inner tuple. I know this is redundant and can be used as second.x, but this should work like right, because it’s nested tuple destructuring? If we’d use var instead of let then x would contain the value assigned from the inner tuple, but it would be completely independent from the new second tuple variable.



-- 
Adrian Zubarev
Sent with Airmail

Am 5. Mai 2017 um 08:04:07, Xiaodi Wu (xiaodi.wu at gmail.com) schrieb:

let (first: a, second: (x: b, y: c)): (first: Int, second: (x: Int, y: Int)) = tuple // fine, unaffected
This would be banned. You are using labels (things ending with a colon) in a pattern (the stuff that comes after the word "let").

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170505/11ff9989/attachment.html>


More information about the swift-evolution mailing list