<div dir="ltr"><div class="markdown-here-wrapper" style=""><pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code class="hljs language-swift" style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248)"><span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">for</span> i <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">in</span> test ?? [] {
<span class="hljs-built_in" style="color:rgb(0,134,179)">print</span>(i)
}
</code></pre>
<p style="margin:0px 0px 1.2em!important">For a more general solution, we could add <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">Optional.flatten()</code> to support optional sequences:</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code class="hljs language-swift" style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248)"><span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">for</span> i <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">in</span> test.flatten() {
<span class="hljs-built_in" style="color:rgb(0,134,179)">print</span>(i)
}
</code></pre>
<div title="MDH:PGRpdiBjbGFzcz0iZ21haWxfZXh0cmEiPmBgYHN3aWZ0PGJyPjwvZGl2PjxkaXYgY2xhc3M9Imdt
YWlsX2V4dHJhIj5mb3IgaSBpbiB0ZXN0ID8/IFtdIHs8L2Rpdj48ZGl2IGNsYXNzPSJnbWFpbF9l
eHRyYSI+Jm5ic3A7ICZuYnNwOyBwcmludChpKTwvZGl2PjxkaXYgY2xhc3M9ImdtYWlsX2V4dHJh
Ij59PC9kaXY+PGRpdiBjbGFzcz0iZ21haWxfZXh0cmEiPmBgYDwvZGl2PjxkaXYgY2xhc3M9Imdt
YWlsX2V4dHJhIj48YnI+PC9kaXY+PGRpdiBjbGFzcz0iZ21haWxfZXh0cmEiPkZvciBhIG1vcmUg
Z2VuZXJhbCBzb2x1dGlvbiwgd2UgY291bGQgYWRkIGBPcHRpb25hbC5mbGF0dGVuKClgIHRvIHN1
cHBvcnQgb3B0aW9uYWwgc2VxdWVuY2VzOjwvZGl2PjxkaXYgY2xhc3M9ImdtYWlsX2V4dHJhIj48
YnI+PC9kaXY+PGRpdiBjbGFzcz0iZ21haWxfZXh0cmEiPmBgYHN3aWZ0PC9kaXY+PGRpdiBjbGFz
cz0iZ21haWxfZXh0cmEiPmZvciBpIGluIHRlc3QuZmxhdHRlbigpIHs8L2Rpdj48ZGl2IGNsYXNz
PSJnbWFpbF9leHRyYSI+Jm5ic3A7ICZuYnNwOyBwcmludChpKTwvZGl2PjxkaXYgY2xhc3M9Imdt
YWlsX2V4dHJhIj59PC9kaXY+PGRpdiBjbGFzcz0iZ21haWxfZXh0cmEiPmBgYDwvZGl2Pg==" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0"></div></div></div>