Data Objects in Kotlin

<p>Data objects are a new Kotlin language feature introduced in version&nbsp;<code>1.7.20</code>&nbsp;and are currently planned to be released in version&nbsp;<code>1.9</code>. We&rsquo;ll take a closer look at what they are and what issue they are trying to solve.</p> <h2>What issue are data objects solving?</h2> <p>Below we have a typical example of a sealed class hierarchy where we are using a&nbsp;<code>sealed interface</code>&nbsp;(we could also use a&nbsp;<code>sealed class</code>) to define possible states for a Profile screen. We are using a&nbsp;<code>data class</code>&nbsp;for the success state and an&nbsp;<code>object</code>&nbsp;for error and loading states since we don&rsquo;t need any additional information.</p> <p><a href="https://medium.com/@domen.lanisnik/data-objects-in-kotlin-1a549bfad657"><strong>Website</strong></a></p>
Tags: Objects Kotlin