<div class="Hi" style="color:rgb(34,34,34)"><div class="Ii" style="height:103px"><div class="Uh" style="height:103px"><div class="di gi  Th" dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word">FWIW, the above only works when &quot;array&quot; is an array or set.  In a generic context you might not even know how to construct an empty one.</div></blockquote><div style="clear:both"></div></div></div></div></div><div style="color:rgb(34,34,34);clear:both"></div><div class="Hi" style="color:rgb(34,34,34)"><div class="Ii" style="height:66px"><div class="Uh" style="height:66px"><div class="di ei  Th" dir="ltr"><div>Right. And for types that don&#39;t conform to ArrayLiteralConvertible or DictionaryLiteralConvertible, there&#39;s no chance to do a shortcut like that.</div></div></div></div></div><div class="Hi" style="color:rgb(34,34,34)"><div class="Ii" style="height:147px"><div class="Uh" style="height:147px"><div class="di gi  Th" dir="ltr"><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div>a?.forEach { object in ... }</div><div><br></div><div>is the generic version I think.</div></div></blockquote><div><br></div><div style="clear:both"></div></div></div></div></div><div style="color:rgb(34,34,34);clear:both"></div><div class="Hi" style="color:rgb(34,34,34)"><div class="Ii" style="height:110px"><div class="Uh" style="height:110px"><div class="di ei  Th" dir="ltr">Unfortunately, this prevents break/continue from being very readable in the &quot;loop&quot; body (IMHO) and doesn&#39;t allow a return out of the enclosing function at all. But yeah, at least that works on any Optional&lt;SequenceType&gt;.</div></div></div></div>