<div dir="ltr">On Sat, Dec 5, 2015 at 11:10 AM, Matthijs Hollemans <span dir="ltr">&lt;<a href="mailto:mail@hollance.com" target="_blank">mail@hollance.com</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><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> <br></div></div></blockquote><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>Another example from the same LinkedList class. It finds the right place to insert a new node:<br></div><div><br></div><div><div style="margin:0px;font-size:16px;font-family:Inconsolata"><span style="color:rgb(187,44,162)">  for</span> next = <span style="color:rgb(79,129,135)">head</span>; next != <span style="color:rgb(187,44,162)">nil</span> &amp;&amp; index &gt; <span style="color:rgb(39,42,216)">0</span>; prev = next, next = next!.<span style="color:rgb(79,129,135)">next</span>, --index { }</div></div><div><br></div><div>Extreme? Probably, but I like it better than the same thing done in five lines of while loop.</div></div></blockquote><div><br></div><div><div>next = head; while next != nil &amp;&amp; index &gt; 0 { prev = next; next = next!.next; --index }</div></div><div><br></div><div>A &#39;for&#39; statement gets away with a single line only because it substitutes semicolons and commas for line breaks. You can do the same with &#39;while&#39;.</div><div><br></div><div>But as Joe pointed out, you can recreate an almost identical &#39;for&#39; with <span style="font-size:13px">autoclosures anyway.</span><br></div><div><br></div><div><br></div></div></div></div>