how can I find an item in a list according to an I...
# getting-started
o
how can I find an item in a list according to an ID that I have, and then replace the item there with the object i have (whose ID i used to find its occurrence in the list)?
a
if you iterate through the MutableList with a MutableIterator, then you can update the value through the iterator
o
doesnt this just need find and map?
Copy code
val changedFilter =         mutableFilterCategories.value?.find { it.categoryId == filterItem.categoryId }
a
find and map will both produce copies of the list — if that’s what you want, go ahead. And you can probably combine that into a single map: someone posted a reply for that and then deleted it
sth like
input.map { if (match(it)) replacement else it }
o
ah right
the syntax inside the map got me