Thanks for the explanation! So
index(..)
is saying, if it's there, get/set/transform it, if not, nothing happens (and return none?). Whereas
at(...)
is pinpoint at an element, if it's there, get/modify/remove it, if not, create it?
I still don't understand why Arrow wouldn't provide a specialized
index(Index.listBy { it.id }, FooId(1))
for fetching by map key or some property in an element in a Set...
But maybe I'm starting to understand why
at(...)
is not implemented for a list (by index at least), because we could get to invalid states like trying to remove an element in the middle of a list (thereby changing all the indices). But it could still be useful to have an
at(At.listBy { it.id }, 1)
where
id
is a property on the elements in the list...