<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Yeah, declaring the `var` immediately inside the `if` block is equivalent to the deprecated `if var` form.<div class=""><br class=""></div><div class="">-Joe</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 17, 2015, at 10:32 AM, Erica Sadun via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><font size="4" class="">My new linter picked up the following as a problem for Swift 3.0, because of my interpretation of the rules in&nbsp;&nbsp;<a href="https://github.com/apple/swift-evolution/blob/master/proposals/0003-remove-var-parameters-patterns.md" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0003-remove-var-parameters-patterns.md</a></font><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp;&nbsp;<b class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">if</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> testStream</b> = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">OutputStream</span>(path: <font color="#d12f1b" class="">aPath</font>) {</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"Testing custom output"</span>, toStream: &amp;testStream)</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"Hello "</span>, terminator: <span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">""</span>, toStream: &amp;testStream)</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"World"</span>, toStream: &amp;testStream)</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"Output sent to </span>\<span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">(</span>testStream.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">path</span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">)"</span>)</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; } <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">else</span> {</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span><span style="" class="">(</span>"Failed to create custom output"<span style="" class="">)</span></div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div></div><div class=""><br class=""></div><div class=""><font size="4" class="">Am I right in assuming this construction will not compile in Swift 3.0? And if so, how should I best recommend re-configuration. I assume the preferred route would be either:</font></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp;&nbsp;<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">if</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> outputStream = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">OutputStream</span>(path: aPath) {</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> testStream = outputStream</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"Testing custom output"</span>, toStream: &amp;testStream)</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"Hello "</span>, terminator: <span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">""</span>, toStream: &amp;testStream)</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"World"</span>, toStream: &amp;testStream)</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"Output sent to </span>\<span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">(</span>testStream.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">path</span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">)"</span>)</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; } <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">else</span> {</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span><span style="" class="">(</span>"Failed to create custom output"<span style="" class="">)</span></div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div></div><div class=""><br class=""></div><div class=""><font size="4" class="">Or using shadowing to mimics the "if let x = x" pattern that has become conventional:</font></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp;&nbsp;<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">if</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> outputStream = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">OutputStream</span>(path: <font color="#d12f1b" class="">aPath</font>) {</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> outputStream = outputStream</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"Testing custom output"</span>, toStream: &amp;outputStream)</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"Hello "</span>, terminator: <span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">""</span>, toStream: &amp;outputStream)</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"World"</span>, toStream: &amp;outputStream)</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"Output sent to </span>\<span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">(</span>outputStream.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">path</span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">)"</span>)</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; } <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">else</span> {</div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span><span style="" class="">(</span>"Failed to create custom output"<span style="" class="">)</span></div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; }</div></div><div class=""><br class=""></div><div class=""><font size="4" class="">Thanks in advance for insight.</font></div><div class=""><font size="4" class=""><br class=""></font></div><div class=""><font size="4" class="">-- E</font></div><div class=""><br class=""></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=RoDF4MveSEMYBIqIJA6ub1g8cOZ-2BVYvqV-2FqygPhjPn-2BMAxdFlrFSXFzsMmeQ4okesgR1GlGD6EkB3gMULx-2FmrufqxIPhZNwE6r-2BTWxy3qQaD-2B4QwK1OIbfMMl7odB3HSc-2FB5dG-2BcPl-2FwTkmLr6gWOh2OnnKtPG-2FEskCazK2PBlsNtpxBkOrnMOgqs-2FJTADiSzHqkad-2BD1sCV2e-2Fvvip-2BXVLUJAaBoLXfs6wyXFWtDI8-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
</div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></body></html>