<div dir="ltr">This may do what you want:<div><br></div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    <span style="color:rgb(187,44,162)">let</span> values: [<span style="color:rgb(112,61,170)">Int</span>] = [<span style="color:rgb(39,42,216)">1</span>,<span style="color:rgb(39,42,216)">2</span>,<span style="color:rgb(39,42,216)">3</span>,<span style="color:rgb(39,42,216)">4</span>]</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    <span style="color:rgb(187,44,162)">if</span> <span style="color:rgb(187,44,162)">let</span> sequence = <span style="color:rgb(49,89,93)">nonEmptySequence</span>(<span style="color:rgb(79,129,135)">values</span>) {</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">        <span style="color:rgb(187,44,162)">for</span> element <span style="color:rgb(187,44,162)">in</span> sequence {</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">            <span style="color:rgb(61,29,129)">print</span>(<span style="color:rgb(209,47,27)">&quot;element: </span>\<span style="color:rgb(209,47,27)">(</span>element<span style="color:rgb(209,47,27)">)&quot;</span>)</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">        }</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    }</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    <span style="color:rgb(187,44,162)">else</span> {</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">        <span style="color:rgb(61,29,129)">print</span>(<span style="color:rgb(209,47,27)">&quot;empty!&quot;</span>)</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">







</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    }</p></div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><br></p>It&#39;s also more flexible, you can do work after the for loop (that work won&#39;t execute in the else), you can also use PeekSequence directly to get the first value. This is handy for something like an average (reduce) where you don&#39;t necessarily have a zero value.</div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><br></p>The implementation can be found here: <a href="https://github.com/therealbnut/PeekSequence">https://github.com/therealbnut/PeekSequence</a></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 26, 2016 at 12:59 AM, Matthew Johnson via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div><br><br>Sent from my iPad</div><span class=""><div><br>On Jan 25, 2016, at 3:41 AM, Howard Lovatt via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div></div><div>It would be easy enough to add:</div><div><br></div><ul style="margin:0px;padding:0px;width:auto;list-style:none"><li style="text-indent:0px;border-left-style:none;margin-left:4em;padding-bottom:0px!important"><font face="UICTFontTextStyleTallBody"><span style="background-color:rgba(255,255,255,0)"><code style="padding:0px!important;border-top-left-radius:0px!important;border-top-right-radius:0px!important;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;background-image:none!important;border:0px!important;float:none!important;min-height:auto!important;line-height:1.1em!important;margin:0px!important;outline:0px!important;overflow:visible!important;vertical-align:baseline!important;width:auto!important;min-height:inherit!important">func</code> <code style="padding:0px!important;border-top-left-radius:0px!important;border-top-right-radius:0px!important;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;background-image:none!important;border:0px!important;float:none!important;min-height:auto!important;line-height:1.1em!important;margin:0px!important;outline:0px!important;overflow:visible!important;vertical-align:baseline!important;width:auto!important;min-height:inherit!important">forEach</code><code style="padding:0px!important;border-top-left-radius:0px!important;border-top-right-radius:0px!important;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;background-image:none!important;border:0px!important;float:none!important;min-height:auto!important;line-height:1.1em!important;margin:0px!important;outline:0px!important;overflow:visible!important;vertical-align:baseline!important;width:auto!important;min-height:inherit!important">(</code></span></font></li><li style="text-indent:0px;border-left-style:none;margin-left:4em;padding-bottom:0px!important"><font face="UICTFontTextStyleTallBody"><span style="background-color:rgba(255,255,255,0)"><code style="padding:0px!important;border-top-left-radius:0px!important;border-top-right-radius:0px!important;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;background-image:none!important;border:0px!important;float:none!important;min-height:auto!important;line-height:1.1em!important;margin:0px!important;outline:0px!important;overflow:visible!important;vertical-align:baseline!important;width:auto!important;min-height:inherit!important">    @</code><code style="padding:0px!important;border-top-left-radius:0px!important;border-top-right-radius:0px!important;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;background-image:none!important;border:0px!important;float:none!important;min-height:auto!important;line-height:1.1em!important;margin:0px!important;outline:0px!important;overflow:visible!important;vertical-align:baseline!important;width:auto!important;min-height:inherit!important">noescape</code> elements <code style="padding:0px!important;border-top-left-radius:0px!important;border-top-right-radius:0px!important;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;background-image:none!important;border:0px!important;float:none!important;min-height:auto!important;line-height:1.1em!important;margin:0px!important;outline:0px!important;overflow:visible!important;vertical-align:baseline!important;width:auto!important;min-height:inherit!important">body</code><code style="padding:0px!important;border-top-left-radius:0px!important;border-top-right-radius:0px!important;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;background-image:none!important;border:0px!important;float:none!important;min-height:auto!important;line-height:1.1em!important;margin:0px!important;outline:0px!important;overflow:visible!important;vertical-align:baseline!important;width:auto!important;min-height:inherit!important">: (</code><code style="padding:0px!important;border-top-left-radius:0px!important;border-top-right-radius:0px!important;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;background-image:none!important;border:0px!important;float:none!important;min-height:auto!important;line-height:1.1em!important;margin:0px!important;outline:0px!important;overflow:visible!important;vertical-align:baseline!important;width:auto!important;min-height:inherit!important">Element</code><code style="padding:0px!important;border-top-left-radius:0px!important;border-top-right-radius:0px!important;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;background-image:none!important;border:0px!important;float:none!important;min-height:auto!important;line-height:1.1em!important;margin:0px!important;outline:0px!important;overflow:visible!important;vertical-align:baseline!important;width:auto!important;min-height:inherit!important">) </code><code style="padding:0px!important;border-top-left-radius:0px!important;border-top-right-radius:0px!important;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;background-image:none!important;border:0px!important;float:none!important;min-height:auto!important;line-height:1.1em!important;margin:0px!important;outline:0px!important;overflow:visible!important;vertical-align:baseline!important;width:auto!important;min-height:inherit!important">throws<font face="UICTFontTextStyleTallBody"> -&gt; Void</font></code><code style="padding:0px!important;border-top-left-radius:0px!important;border-top-right-radius:0px!important;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;background-image:none!important;border:0px!important;float:none!important;min-height:auto!important;line-height:1.1em!important;margin:0px!important;outline:0px!important;overflow:visible!important;vertical-align:baseline!important;width:auto!important;min-height:inherit!important">,</code></span></font></li><li style="text-indent:0px;border-left-style:none;margin-left:4em;padding-bottom:0px!important"><font face="UICTFontTextStyleTallBody"><span style="background-color:rgba(255,255,255,0)"><code style="padding:0px!important;border-top-left-radius:0px!important;border-top-right-radius:0px!important;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;background-image:none!important;border:0px!important;float:none!important;min-height:auto!important;line-height:1.1em!important;margin:0px!important;outline:0px!important;overflow:visible!important;vertical-align:baseline!important;width:auto!important;min-height:inherit!important">    @noescape otherwise otherwise: () throws -&gt; Void</code></span></font></li><li style="text-indent:0px;border-left-style:none;margin-left:4em;padding-bottom:0px!important"><font face="UICTFontTextStyleTallBody"><span style="background-color:rgba(255,255,255,0)"><code style="padding:0px!important;border-top-left-radius:0px!important;border-top-right-radius:0px!important;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;background-image:none!important;border:0px!important;float:none!important;min-height:auto!important;line-height:1.1em!important;margin:0px!important;outline:0px!important;overflow:visible!important;vertical-align:baseline!important;width:auto!important;min-height:inherit!important">) </code><code style="padding:0px!important;border-top-left-radius:0px!important;border-top-right-radius:0px!important;border-bottom-right-radius:0px!important;border-bottom-left-radius:0px!important;background-image:none!important;border:0px!important;float:none!important;min-height:auto!important;line-height:1.1em!important;margin:0px!important;outline:0px!important;overflow:visible!important;vertical-align:baseline!important;width:auto!important;min-height:inherit!important">rethrows</code></span></font></li></ul><div><font face="monospace"><br></font></div><div><font face="monospace">to the standard library or write it yourself.</font></div></div></blockquote><div><br></div></span><div>Not unless / until we get the ability for a noescape closure to influence control flow (break, return, etc).  Even then this is clunkier than adding else to the language would be.</div><div><div class="h5"><br><blockquote type="cite"><div><div><br>On 23 Jan 2016, at 12:59 PM, Félix Cloutier via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div>I frequently need something like that and I&#39;d like to have it in Swift too.<br><div>
<br><span style="color:rgb(0,0,0);font-family:&#39;Lucida Grande&#39;;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none">Félix</span>
</div>

<br><div><blockquote type="cite"><div>Le 22 janv. 2016 à 13:22:45, Ben Langmuir via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; a écrit :</div><br><div><div>Previous discussion here:<br><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001110.html" target="_blank">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001110.html</a><br><br><br><blockquote type="cite">On Jan 22, 2016, at 8:22 AM, Lee M via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br><br>This has likely been discussed already, but I haven&#39;t been able to find it anywhere.<br>Example:<br><br>    let items: Int = []<br><br>    for item in items {<br>        print(item)<br>    }<br>    else {<br>        print(&quot;No items&quot;)<br>    }<br>_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></blockquote><br>_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></div></blockquote></div><br></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></div></div></div><br>_______________________________________________<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/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>