Could someone explain how exactly the copy method for Kotlin data classes work? It seems like for some members, a (deep) copy is not actually created and the re
Beware of those answers who are just copying list reference from an old object into the new one. Only quick way of deep copying I have found is to either serialize/deserialize objects i.e. convert the objects into JSON and then transform them back to POJO. If you are using GSON, here is the piece of code:
class Foo {
fun deepCopy() : Foo {
return Gson().fromJson(Gson().toJson(this), this.javaClass)
}
}