Stefan Kanev
12/24/2019, 12:32 PMdata class User(val name: String, val location: Location)
data class Location(val city: City, val somethingElse: String) // for example
data class City(val name: String, val country: String)
I have a user and I want to change the city name, getting a copy of user with everything else on the chain unchanged. I can do it with copy:
val newUser = user.copy(location = user.location.copy(city = user.location.city.copy(name = "New name")))
but that's far too long esentially I'd like to be able to do something shorter like:
val newUser = user.copy { it.location.city.name = "New name" }
I don't think the above could get gotten to work, but is there something in those lines I can do?
(also, not my actual data structure, but sufficient for this example)
Thanks šRoman Q.
12/24/2019, 1:02 PMStefan Kanev
12/24/2019, 2:08 PMRoman Q.
12/24/2019, 2:10 PMStefan Kanev
12/24/2019, 2:13 PMRoman Q.
12/24/2019, 2:14 PM