<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 2, 2016, at 5:13 PM, Jordan Rose via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> 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=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 2, 2016, at 16:53, Ross O'Brien via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">For example: getting the first element from an array of optionals. Here's my sample trivial example:</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span class="" style="white-space: pre;">        </span><span style="color: rgb(187, 44, 162);" class="">var</span><span class="Apple-converted-space"> </span>array : [<span style="color: rgb(112, 61, 170);" class="">Int</span>?] = []</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span class="" style="white-space: pre;">        </span><span style="color: rgb(187, 44, 162);" class="">if</span><span class="Apple-converted-space"> </span><span style="color: rgb(187, 44, 162);" class="">let</span><span class="Apple-converted-space"> </span>x = array[<span style="color: rgb(39, 42, 216);" class="">0</span>]<span class="Apple-converted-space"> </span><span style="color: rgb(187, 44, 162);" class="">where</span><span class="Apple-converted-space"> </span>array.<span style="color: rgb(112, 61, 170);" class="">count</span><span class="Apple-converted-space"> </span>><span class="Apple-converted-space"> </span><span style="color: rgb(39, 42, 216);" class="">0</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span class="" style="white-space: pre;">        </span>{</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span class="" style="white-space: pre;">                </span><span style="color: rgb(61, 29, 129);" class="">print</span>(x)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span class="" style="white-space: pre;">        </span>}</div></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">This code doesn't work. The array index is out of range. But there's no way I know of to rearrange the 'if' to ensure the array isn't empty before binding to the first element - the developer has to write a nested if statement.</div></div></blockquote><br class=""></div><div class="">We already allow this, with commas:</div><br class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">var array: [Int?] = []</div><div class="">if !array.isEmpty, let x = array[0] {</div><div class=""> print(x)</div><div class="">}</div></blockquote></div></div></blockquote></div><br class=""><div class="">That's true, but there are some problematic ambiguities with our current syntax, since 'let' and 'case' conditions both admit multiple sub-conditions also separated by commas, e.g. 'if let x = y, y = z { }' or 'if case let x = y, let y = z'. Using ';' for this purpose would be less ambiguous.</div><div class=""><br class=""></div><div class="">-Joe</div></body></html>