liminal
08/15/2023, 2:08 PMSam
08/15/2023, 2:15 PMMyPost
. My first thought is that a simple solution would involve several nested calls to copy
. If you want something a bit smarter you could look at #arrow Optics.liminal
08/15/2023, 2:16 PMliminal
08/15/2023, 2:17 PMSam
08/15/2023, 2:19 PMliminal
08/15/2023, 2:21 PMSam
08/15/2023, 2:21 PMSam
08/15/2023, 2:22 PMval newPost = post.copy(
rows = post.rows.map { row ->
row.copy(columns = row.columns.map { column ->
column.copy(sections = column.sections.map { oldSection ->
if (oldSection.id == newSection.id) newSection else oldSection
})
})
}
)
Sam
08/15/2023, 2:24 PMSam
08/15/2023, 2:26 PMliminal
08/15/2023, 2:32 PM