Free AI web copilot to create summaries, insights and extended knowledge, download it at here
1512
Abstract
oops: <code>for</code>, <code>while</code>, <code>do-while</code></p><h1 id="e9b5">For</h1><p id="084c"><code>for</code> in Kotlin works the same way as the <a href="https://docs.oracle.com/javase/tutorial/java/nutsandbolts/for.html">enhanced <code></code>for statement</a> in Java.</p>
<figure id="4809">
<div>
<div>
<img class="ratio" src="http://placehold.it/16x9">
<iframe class="" src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fpl.kotl.in%2FsJChKhWS0&display_name=Kotlin+Playground&url=https%3A%2F%2Fpl.kotl.in%2FsJChKhWS0&image=https%3A%2F%2Fplay.kotlinlang.org%2Fassets%2Fog-image.png&key=a19fcc184b9711e1b4764040d3dc5c07&type=text%2Fhtml&schema=kotl" allowfullscreen="" frameborder="0" height="300" width="800">
</div>
</div>
</figure></iframe></div></div></figure><ol><li>Loops through each cake in the list.</li><li>We’ll get to <a href="https://readmedium.com/string-templates-92eb82841cbb">string templates</a> (i.e. the <code>$cake</code> part) in a bit</li></ol><p id="a6b4">You might be wondering how to emulate the classic <code>for</code> loop, e.g. <code>for(int i = 0; i < 10; i++)</code>. This can be achieved using the above form in combination with <a href="https://readmedium.com/ranges-288a61ec080e">ranges</a>, which we’ll talk about soon.</p><h1 id="bb25">while and do-while</h1><p id="2a7f"><code>while</code> and <code>do-while</code> con
Options
structs work similarly to most languages as well.</p>
<figure id="a061">
<div>
<div>
<img class="ratio" src="http://placehold.it/16x9">
<iframe class="" src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fpl.kotl.in%2FN8rQ3-1cX&display_name=Kotlin+Playground&url=https%3A%2F%2Fpl.kotl.in%2FN8rQ3-1cX&image=https%3A%2F%2Fplay.kotlinlang.org%2Fassets%2Fog-image.png&key=a19fcc184b9711e1b4764040d3dc5c07&type=text%2Fhtml&schema=kotl" allowfullscreen="" frameborder="0" height="300" width="800">
</div>
</div>
</figure></iframe></div></div></figure><ol><li>Executes the block while the condition is true.</li><li>Executes the block first and then checks the condition.</li></ol><p id="b7a1">Go back to the <a href="https://readmedium.com/when-construct-c90606274897">When Construct</a>, jump to the <a href="https://readmedium.com/table-of-contents-c52573cfa291">Table of Contents</a>, or continue to the <a href="https://readmedium.com/conditional-expression-7fb52a02b767">Conditional Expression</a>.</p><figure id="8ecd"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*biBSB579iezsNvEQ_NMLBg.png"><figcaption><a href="https://www.etnetera.cz/prace-u-nas?utm_source=medium&utm_medium=GabrielShanahan&utm_campaign=KotlinPrimer&utm_content=join-our-team&utm_term=KotlinPrimer#pozice">Join me in Etnetera</a></figcaption></figure></article></body>