<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 16:53, Ross O'Brien 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=""><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">&nbsp;</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">&nbsp;</span><span style="color: rgb(187, 44, 162);" class="">let</span><span class="Apple-converted-space">&nbsp;</span>x = array[<span style="color: rgb(39, 42, 216);" class="">0</span>]<span class="Apple-converted-space">&nbsp;</span><span style="color: rgb(187, 44, 162);" class="">where</span><span class="Apple-converted-space">&nbsp;</span>array.<span style="color: rgb(112, 61, 170);" class="">count</span><span class="Apple-converted-space">&nbsp;</span>&gt;<span class="Apple-converted-space">&nbsp;</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>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="">&nbsp; print(x)</div><div class="">}</div></blockquote><br class=""><div class="">Jordan</div></body></html>