we need to change an attribute that's pretty deep in a nested structure of immutable data classes, is there no simpler/more elegant way to do this in Kotlin? or do we have to use lenses or whatever?
Copy code
kotlin
return taxableOrder
.copy(
checks = taxableOrder
.checks
?.map { taxableCheck ->
taxableCheck.copy(selections = taxableCheck
.selections
?.map { taxableSelection ->
taxableSelection.copy(taxCategory = TaxableSelection.TaxCategory.HOT_FOOD) //this is really the only thing we want to change
}
)
}
)
// but we still have to map and copy every step on the way into that nested attribute 🫠
@Sam all my prayers go towards a real immutable DSL. Like the Optics DSL but 1st class, and better 😂 Oof all comments are 3+ years old.
Has it been that long since this was announced/shared 🤣 Jeez time flies.