You might want this if you want to mutate the orig...
# getting-started
e
You might want this if you want to mutate the original list.
.map()
creates a copy of the original list
o
it makes sense, but it’s weird that I get this ..I tried to make it mutable list, same

https://i.imgur.com/UaqMvEv.jpg

lol, if I say I want to use set() and then do the IDE suggestion and make it go back to above, it stops complaining
m
Probably it's changing the list for a mutableList
o
yes it was
ok so if I grab the item again through `
Copy code
it.items.toMutableList()[searchMatchIdx].toggled
it’s still false
I think I settled on this and it was a mistake, to place toMutableList() here `
Copy code
it.items.toMutableList()[searchMatchIdx] =
    it.items[searchMatchIdx].copy(toggled = true)
yea thats wrong
m
it's the order of the list important? if not you can do
Copy code
val elem = it.items.first { ..condition.. }
val list = (it.items - elem) + elem.copy(toggled = true)
e
toMutableList()
also makes a copy of the original list. You should define the original list as mutable if you want to mutate it.