Hi again! How do I change a specific value in a li...
# arrow
d
Hi again! How do I change a specific value in a list with optics @simon.vergauwen?
Copy code
@optics data class Foo(val list: List<Bar>)
@optics data class Bar(val id: Int, val isChecked: Boolean)

// I need to change isChecked for say, a Bar that's id (NOT index in list) is 2?
s
Hey @dave08, Sorry for the late reply. I was out in August. You should be able to do this with the
Index
https://apidocs.arrow-kt.io/arrow-optics/arrow.optics.typeclasses/-index/index.html type. I see it's documentation is a bit less than desired in the API docs, and it's also not mentioned on the website. I think an issue for that is in order.
d
There's quite a few things that aren't clear from the current docs on optics... like the difference between
index
and
at
in this case, and I think that the default implementations of index use the index in the list... whereas I needed to use an index from the object itself, so I had to implement my own