<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">What about just use</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">test?.forEach { print($0) }</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">Zhaoxin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Feb 11, 2017 at 7:48 PM, Tino Heth 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 style="word-wrap:break-word">This one started over at swift-users, with a question on how to deal with looping over containers that may be nil.<div><br></div><div>Imho the beauty of the feature is that it&#39;s simple enough to be explained in the subject line, but here is the &quot;long&quot; story:</div><div><br></div><div><div><div><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">let</span><span style="font-variant-ligatures:no-common-ligatures"> test: [</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">Int</span><span style="font-variant-ligatures:no-common-ligatures">]? = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">nil</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><div style="color:rgb(0,132,0);margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">// this is possible now</span></div><div style="color:rgb(0,0,0);margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2">if</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2">let</span><span style="font-variant-ligatures:no-common-ligatures"> test = test {</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><span class="m_-4897680756673453263Apple-tab-span" style="white-space:pre-wrap">        </span>for</span><span style="color:rgb(0,0,0);font-variant-ligatures:no-common-ligatures"> i </span><span style="color:rgb(186,45,162);font-variant-ligatures:no-common-ligatures">in</span><span style="color:rgb(0,0,0);font-variant-ligatures:no-common-ligatures"> test {</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><span class="m_-4897680756673453263Apple-tab-span" style="white-space:pre-wrap">                </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(62,30,129)">print</span><span style="font-variant-ligatures:no-common-ligatures">(i)</span></div><div style="color:rgb(0,0,0);margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><span class="m_-4897680756673453263Apple-tab-span" style="white-space:pre-wrap">        </span>}</span></div><div style="color:rgb(0,0,0);margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">}</span></div><div style="color:rgb(186,45,162)"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)"><div style="color:rgb(0,132,0);margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">// how it could be written with a modified keyword</span></div></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">for</span><span style="font-variant-ligatures:no-common-ligatures"> i </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">in?</span><span style="font-variant-ligatures:no-common-ligatures"> test</span><span style="font-variant-ligatures:no-common-ligatures"> {</span></div></span></div></div><div><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><span class="m_-4897680756673453263Apple-tab-span" style="white-space:pre-wrap">        </span>print</span><span style="font-variant-ligatures:no-common-ligatures">(i)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">}</span></div><div><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div>I&#39;ve been thinking &quot;in?&quot; had been brought up long ago, but as I haven&#39;t found such a proposal, I probably confused it with the cancelled plan to write one on my own (or I just was to stupid to search ;-).</div><div><br></div><div>Syntactic sugar like this is definitely nothing that has priority now, but discussing it shouldn&#39;t be a big distraction — and if it turns into a proposal that as well survives review, it might be even simple enough to act as a trigger for me to finally get my hands on some real work for Swift ;-)</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>- Tino</div></font></span></span></div></div></div><br>______________________________<wbr>_________________<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/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br></blockquote></div><br></div>