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

Rien Rien at Balancingrock.nl
Fri May 5 01:39:07 CDT 2017


I think your misunderstanding helped a lot of people understand what is at issue here :-)

It did for me!

+1


Regards,
Rien

Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Balancingrock
Project: http://swiftfire.nl - A server for websites build in Swift






> On 05 May 2017, at 08:33, Adrian Zubarev via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 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").
>> 
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list