<div dir="ltr">I support the first part, removing `case let` in a switch. I actually prefer one let out front in many ways but I have a much stronger preference for eliminating a 'style' choice that dramatically impacts the interpretation of the code. Binding each value is more explicit, so I am fine with it winning.<div><br></div><div>The `if case` stuff… I don't really agree with as much. </div><div><br></div><div>TJ</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 6, 2017 at 7:35 PM, Erica Sadun via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Bug report filed with warning emitting request: </div><div><br></div><div><a href="https://bugs.swift.org/browse/SR-4174" target="_blank">https://bugs.swift.org/browse/<wbr>SR-4174</a></div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-- E</div></font></span><div><div class="h5"><div><br></div><div><blockquote type="cite"><div>On Mar 1, 2017, at 1:58 PM, Pyry Jahkola <<a href="mailto:pyry.jahkola@iki.fi" target="_blank">pyry.jahkola@iki.fi</a>> wrote:</div><br class="m_-585721093709060955Apple-interchange-newline"><div><div style="word-wrap:break-word">I guess I should also include the example where the user actually wanted the oldValue to be "x":<div><br></div><div><div><div><font face="Menlo"> <b>if case let</b> .two(newValue, value) = example, </font><span style="font-family:Menlo">value == oldValue</span><span style="font-family:Menlo"> { ... }</span></div></div></div><div><div><div><font face="Menlo"><br></font></div><div>No surprises there, even if another conditional is required.</div><div><br></div><div>— Pyry</div></div></div><div><br><div><blockquote type="cite"><div>On 1 Mar 2017, at 22.53, Pyry Jahkola via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br class="m_-585721093709060955Apple-interchange-newline"><div><div style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Erica,</div><div style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><span style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">Instead of going into all these lengths introducing new syntax, why not simply turn it into a warning when a `</span><b style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">case let</b><span style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">` binding shadows an existing variable with the exact same type (which supposedly also conforms to Equatable)?</span><div style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Examples, including how to silence the said warning:<div><br></div><div><font face="Menlo"> <span class="m_-585721093709060955Apple-converted-space"> </span><b>enum</b><span class="m_-585721093709060955Apple-converted-space"> </span>Value<T> {<span class="m_-585721093709060955Apple-converted-space"> </span><b>case</b><span class="m_-585721093709060955Apple-converted-space"> </span>one(T), two(T, T), three(T, T, T) }</font></div><div><font face="Menlo"> </font></div><div><font face="Menlo"> <span class="m_-585721093709060955Apple-converted-space"> </span><b>let</b><span class="m_-585721093709060955Apple-converted-space"> </span>example: </font><span style="font-family:Menlo">Value<String></span><span style="font-family:Menlo"> = .two("a", "b")</span></div><div><font face="Menlo"> <span class="m_-585721093709060955Apple-converted-space"> </span><b>let</b><span class="m_-585721093709060955Apple-converted-space"> </span>oldValue = "x"</font></div><div><font face="Menlo" color="#929292"> // (Besides, you probably intended </font><span style="font-family:Menlo">`</span><font face="Menlo" color="#929292">oldValue</font><span style="font-family:Menlo">`</span><font face="Menlo" color="#929292"> to be a </font><span style="font-family:Menlo">`</span><font face="Menlo" color="#929292">Character</font><span style="font-family:Menlo">`</span><font face="Menlo" color="#929292"> in your</font></div><div><font color="#929292"><font face="Menlo"> // </font><span style="font-family:Menlo">example. </span><span style="font-family:Menlo">Well, it's a </span></font><span style="font-family:Menlo">`</span><font color="#929292"><span style="font-family:Menlo">String</span></font><span style="font-family:Menlo">`</span><font color="#929292"><span style="font-family:Menlo"> in mine.)</span></font></div><div><font face="Menlo"> </font></div><div><font face="Menlo"> <span class="m_-585721093709060955Apple-converted-space"> </span><b>if case let</b><span class="m_-585721093709060955Apple-converted-space"> </span>.two(newValue, oldValue) = example { ... }</font></div><div><font face="Menlo" color="#929292"> // ~~~~~~~~</font></div><div><font face="Menlo"><b><font color="#929292"> //<span class="m_-585721093709060955Apple-converted-space"> </span></font>warning:<font color="#929292"><span class="m_-585721093709060955Apple-converted-space"> </span>'oldValue' shadows an existing variable of same type 'String'</font></b></font></div><div><font face="Menlo"> </font></div><div><font face="Menlo"> <span class="m_-585721093709060955Apple-converted-space"> </span><b>if case let</b><span class="m_-585721093709060955Apple-converted-space"> </span>.two(newValue, (oldValue)) = example { </font><span style="font-family:Menlo">assert(oldValue == "b") </span><span style="font-family:Menlo">}</span></div><div><font face="Menlo" color="#929292"> // Ok, adding extra parentheses silences the warning.</font></div><div><font face="Menlo"><br></font></div><div><font face="Menlo"> <span class="m_-585721093709060955Apple-converted-space"> </span><b>if case let</b><span class="m_-585721093709060955Apple-converted-space"> </span>.one(example) = example { ... }</font></div><div><font color="#929292"><font face="Menlo"> // Ok, because there's no way the author would equate the </font><span style="font-family:Menlo">`</span><span style="font-family:Menlo">example: String</span><span style="font-family:Menlo">`</span></font></div><div><font color="#929292"><font face="Menlo"> // in the LHS to the </font><span style="font-family:Menlo">`</span><font face="Menlo">example: Value<String></font><span style="font-family:Menlo">`</span><font face="Menlo"> of the RHS.</font></font></div><div><font face="Menlo"> </font></div><div><font face="Menlo"> <span class="m_-585721093709060955Apple-converted-space"> </span><b>let</b><span class="m_-585721093709060955Apple-converted-space"> </span>maybe: Optional = "perhaps"</font></div><div><font face="Menlo"> <span class="m_-585721093709060955Apple-converted-space"> </span><b>if case let</b><span class="m_-585721093709060955Apple-converted-space"> </span>maybe? = maybe { ... }</font></div><div><font face="Menlo"> <span class="m_-585721093709060955Apple-converted-space"> </span><b>if case let</b><span class="m_-585721093709060955Apple-converted-space"> </span>.some(maybe) = maybe { ... }</font></div><div><font face="Menlo" color="#929292"> // Again, none of these examples would be affected by the warning, because</font></div><div><font color="#929292"><font face="Menlo"> // the </font><span style="font-family:Menlo">`</span><font face="Menlo">maybe: String</font><span style="font-family:Menlo">`</span><font face="Menlo"> bound in the </font><span style="font-family:Menlo">`</span><font face="Menlo">case let</font><span style="font-family:Menlo">` has a different type than</span></font></div><div><span style="font-family:Menlo"><font color="#929292"> // the `maybe: String?` in the outer scope.</font></span></div><div><br></div><div>Personally, I do like the convenience that I can bind several variables with one `<b>let</b>` keyword in a case expression. And I can't see the appeal to making `~=`, let alone a completely new special-syntax assignment operator, more prominent in Swift.</div><div><br></div><div>— Pyry</div><div><br><div><blockquote type="cite"><div>On 28 Feb 2017, at 21.01, Erica Sadun via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br class="m_-585721093709060955Apple-interchange-newline"><div><div style="word-wrap:break-word"><div style="word-wrap:break-word">The following draft proposal addresses one matter of substance (eliminating edge case errors by adopting at-site conditional binding) and one of style (using the pattern match operator consistently). Its discussion was deferred from Phase 1 and remains in a fairly early stage. Your feedback will help me decide whether this is a proposal I want to keep developing or one that I should set aside and focus on other matters. Thank you. -- E<div><br></div><div>The work-in-progress gist is here: <a href="https://gist.github.com/erica/06dad9bbe1a70290fe6b89a64f73bc0c" target="_blank">https://gist.github.com/<wbr>erica/<wbr>06dad9bbe1a70290fe6b89a64f73bc<wbr>0c</a> </div><div><br></div><div><h1 style="box-sizing:border-box;margin-right:0px;margin-bottom:16px;margin-left:0px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';background-color:rgb(255,255,255);margin-top:0px!important">Simplifying case syntax</h1><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)"><li style="box-sizing:border-box">Proposal: TBD</li><li style="box-sizing:border-box;margin-top:0.25em">Author: <a href="https://github.com/erica" style="box-sizing:border-box;background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">Erica Sadun</a></li><li style="box-sizing:border-box;margin-top:0.25em">Status: TBD</li><li style="box-sizing:border-box;margin-top:0.25em">Review manager: TBD</li></ul><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';background-color:rgb(255,255,255)"><a id="m_-585721093709060955user-content-introduction" class="m_-585721093709060955anchor" href="https://gist.github.com/erica/06dad9bbe1a70290fe6b89a64f73bc0c#introduction" style="box-sizing:border-box;background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" target="_blank"><u></u><u></u><u></u><u></u></a>Introduction</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)">This proposal re-architects case syntax grammar to reduce potential errors and simplify unwrapping enumerations. </p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)">Swift-evolution thread: <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20161024/tbd.html" style="box-sizing:border-box;background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">[Pitch] Reimagining <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">guard case</code>/<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">if case</code></a></p><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';background-color:rgb(255,255,255)"><a id="m_-585721093709060955user-content-motivation" class="m_-585721093709060955anchor" href="https://gist.github.com/erica/06dad9bbe1a70290fe6b89a64f73bc0c#motivation" style="box-sizing:border-box;background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" target="_blank"><u></u><u></u><u></u><u></u></a>Motivation</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)">In its current design, Swift case binding suffers from two weaknesses.</p><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)"><li style="box-sizing:border-box">Mixed external and internal <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">let</code>/<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">var</code> binding may introduce errors from uncommon edge cases.</li><li style="box-sizing:border-box;margin-top:0.25em">Real-world users may not consider the parallel construction between <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">if case</code>/<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">guard case</code> with <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">switch</code>statements or naturally connect the two layouts.</li></ul><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';background-color:rgb(255,255,255)"><a id="m_-585721093709060955user-content-internal-case-binding" class="m_-585721093709060955anchor" href="https://gist.github.com/erica/06dad9bbe1a70290fe6b89a64f73bc0c#internal-case-binding" style="box-sizing:border-box;background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" target="_blank"><u></u><u></u><u></u><u></u></a>Internal Case Binding</h3><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)">When pattern matching, it's common to bind a variable or constant. It's uncommon but legal to use a bound value as an argument. Adopting an "always explicit, always within the parentheses" rule adds consistency and safety to Swift. </p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)">Consider the following enumeration and values:</p><div class="m_-585721093709060955highlight m_-585721093709060955highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)"><pre style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal"><span class="m_-585721093709060955pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_-585721093709060955pl-c" style="box-sizing:border-box">//</span> An enum with one, two, or three associated values</span>
<span class="m_-585721093709060955pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="m_-585721093709060955pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_-585721093709060955pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Value</span><<span class="m_-585721093709060955pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">T</span>> { <span class="m_-585721093709060955pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-585721093709060955pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">one</span>(T), <span class="m_-585721093709060955pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">two</span>(T, T), <span class="m_-585721093709060955pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">three</span>(T, T, T) }
<span class="m_-585721093709060955pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_-585721093709060955pl-c" style="box-sizing:border-box">//</span> An example with two associated values</span>
<span class="m_-585721093709060955pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="m_-585721093709060955pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> example2<span class="m_-585721093709060955pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span> <span class="m_-585721093709060955pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Value</span><span class="m_-585721093709060955pl-k" style="box-sizing:border-box;color:rgb(167,29,93)"><</span><span class="m_-585721093709060955pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Character</span><span class="m_-585721093709060955pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">></span> <span class="m_-585721093709060955pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> .<span class="m_-585721093709060955pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">two</span>(<span class="m_-585721093709060955pl-s" style="box-sizing:border-box;color:rgb(24,54,145)"><span class="m_-585721093709060955pl-pds" style="box-sizing:border-box">"</span>a<span class="m_-585721093709060955pl-pds" style="box-sizing:border-box">"</span></span>, <span class="m_-585721093709060955pl-s" style="box-sizing:border-box;color:rgb(24,54,145)"><span class="m_-585721093709060955pl-pds" style="box-sizing:border-box">"</span>b<span class="m_-585721093709060955pl-pds" style="box-sizing:border-box">"</span></span>)
<span class="m_-585721093709060955pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_-585721093709060955pl-c" style="box-sizing:border-box">//</span> A bound symbol</span>
<span class="m_-585721093709060955pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="m_-585721093709060955pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> oldValue <span class="m_-585721093709060955pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> <span class="m_-585721093709060955pl-s" style="box-sizing:border-box;color:rgb(24,54,145)"><span class="m_-585721093709060955pl-pds" style="box-sizing:border-box">"</span>x<span class="m_-585721093709060955pl-pds" style="box-sizing:border-box">"</span></span></pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)">This code's goal is to conditionally bind <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">newValue</code> and pattern match the value stored in the <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">oldValue</code> symbol. The first example succeeds. The second example compiles and runs but does not match the coder's intent. Using an external <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">let</code>creates a new <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">oldValue</code> shadow instead of pattern matching <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">oldValue</code>'s stored value.</p><pre style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:16px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)"><code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;padding:0px;margin:0px;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal;border:0px;display:inline;overflow:visible;line-height:inherit;word-wrap:normal">// Safe
if case .two(let newValue, oldValue) = example2 {
...
}
// Syntactically legal but incorrect
if case let .two(newValue, oldValue) = example2 {
...
}</code></pre></div></div></div></div></blockquote>(…)</div></div><div><br></div></div><span style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">______________________________<wbr>_________________</span><br style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">swift-evolution mailing list</span><br style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="mailto:swift-evolution@swift.org" style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">swift-evolution@swift.org</a><br style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a></div></blockquote></div><br><div>
<div style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">-- </div><div style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Pyry Jahkola</div><div style="font-family:Helvetica;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="mailto:pyry.jahkola@iki.fi" target="_blank">pyry.jahkola@iki.fi</a></div>
</div>
<br></div></div></div></blockquote></div><br></div></div></div><br>______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br></blockquote></div><br></div>