I have data classes with some properties the same....
# announcements
m
I have data classes with some properties the same. Is it possible to define an interface for them, so that
copy()
works?
Copy code
interface WithProp1 {
    val prop1
}
data class MyClassA(override val prop1: Boolean, val propOther: Int) : WithProp1
data class MyClassB(override val prop1: Boolean, val propString: String) : WithProp1
Copy code
val withProp1: WithProp1 = ...
val modified = withProp1.copy(prop1 = true)