Hi, I'm using Arrow Optics and I'm trying to modif...
# arrow
g
Hi, I'm using Arrow Optics and I'm trying to modify the items of a list based on the list's index. In pseudo code (I even tried with
FilterIndex
without succeeding):
Copy code
val lens = MyClass.listProperty
              .every(ListFilterForIndex { index -> index % 2 })
              .itemProperty
var myObject = MyClass()
myObject = lens.modify(myObject) { "modified string" }
g
@pakoito Nothing fails, I wrote it in pseudo code, so that every isn't a valid code at all
p
without succeeding
what isn't working?
what's not happening?
g
I simply don't know which method I can use to modify the items of a list using a lambda for the index instead of using
index(ListIndex(), 2)
. The line
every(ListFilterForIndex { index -> index % 2 })
was invented by myself, it isn't valid, it doesn't even compile since
ListFilterIndex
doesn't implement
Each<T>
.
r
@simon.vergauwen may know if there is a way
g
@simon.vergauwen Understood, thanks very much for your help!
👍 1
137 Views