Hey you might want to have a look to my project “imko” (immutable kotlin objects) which provides a cool way of defining immutable objects and a cool syntax for creating new versions of it:
Consider having a reference tree like
Object1
| \
| \
| Object2
| | \
| | \
| | Int2
| Int1
|
String
Creating a new verion with a different “int2” could look like
val version2 =
object1{
object2{
int2{
times(2)
}
}
}
Or
val version2 = object1{ object2{ int2{ times(2) } } }
I think this would be the equivalent in doing the same stuff with data-classes
val version2 = object1.copy(object2=object1.object2.copy(int2=object1.object2.int2.times(2)))
Let me know what you think about it ![]()