You are currently viewing How do we add properties to an existing data class?

How do we add properties to an existing data class?

New Kotlin (1.4.10) user here. I recently came across a situation where I have a data class from a dependency (jar) on which I need a couple more properties on top. This is quite easy in java (inheritance) but in Kotlin there does not seem to be a way to do this(data classes are final by default).

Can you tell me if there is some other Kotlin feature I missed exploring that can help me achieve this ? Maybe this is an anti-pattern I’m not sure.

submitted by /u/coolkish262
[link] [comments]