Free AI web copilot to create summaries, insights and extended knowledge, download it at here
1627
Abstract
c">
<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%2FnqceEy1cw&display_name=Kotlin+Playground&url=https%3A%2F%2Fpl.kotl.in%2FnqceEy1cw&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><p id="97ed">Objects are in fact types that have a single instance, both of which are denoted by the same word. This means that <code>MathStuff</code> can represent a type, but it can also represent a value, depending on the context. We’ve actually <a href="https://readmedium.com/types-142c319e5923">already talked about this</a>, when we talked about <code>Unit</code>.</p>
<figure id="d54d">
<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%2F68YLNY-V6&display_name=Kotlin+Playground&url=https%3A%2F%2Fpl.kotl.in%2F68YLNY-V6&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><p id="aa34">Nat
Options
urally, the above code is only to demonstrate how an object can appear both as a type and as a value. Other than that, the above design doesn’t really make much sense — <code>Config</code> is a singleton, so it makes no sense to accept it as a parameter, it should just be accessed directly from within the code:</p>
<figure id="89ca">
<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%2F1zsDp3RJQ&display_name=Kotlin+Playground&url=https%3A%2F%2Fpl.kotl.in%2F1zsDp3RJQ&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><p id="d85b">Go back to <a href="https://readmedium.com/data-classes-97cbd6bfa0b7">Data Classes</a>, jump to the <a href="https://readmedium.com/table-of-contents-c52573cfa291">Table of Contents</a>, or continue to <a href="https://readmedium.com/object-expressions-ce915bf64873">Object Expressions</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>