bod
10/06/2023, 3:49 PMephemient
10/06/2023, 3:53 PMclass
to data class
I guessbod
10/06/2023, 3:54 PMsimilar to the suggestion for updatingI don't get such suggestion. It seems the object one is related to the fact that it's inside a sealed interfacetoclass
I guessdata class
Klitos Kyriacou
10/06/2023, 4:29 PMwhen
clauses, but if the object comes from Java serialization, or from a mocking framework, the object may not be an actual singleton and the ==
operator used by the when
clause may return false even for objects of the same type. Making it a data object
fixes this possibility.bod
10/06/2023, 4:32 PMCasey Brooks
10/06/2023, 4:36 PMtoString()
of a non-data object is platform-dependent while toString()
of a data class is not. This can be problematic in KMP apps for things like logging, when the platform’s representation doesn’t include any type information.
For example, see how the toString()
here changes between JVM and JS targets (and how completely useless the JS version is) https://pl.kotl.in/OZ8JtYfeCbod
10/06/2023, 4:40 PMdata object
exists and object
is not doing "the right thing" by default 🙂 But I suppose I'm not seeing the full picture (maybe that would be a breaking change...)Casey Brooks
10/06/2023, 4:44 PMdata object
, and it would increase the binary size significantly to make them all data objects. A normal object is simple a singleton class with no extra ceremony. It’s just that the common semantics of an object inside a sealed class is closer to that of a data class that doesn’t have members, rather than an actual singleton, hence the addition of data object
and its Intellij inspectionbod
10/06/2023, 4:46 PM