Is it possible to modify an object by applying mul...
# arrow
n
Is it possible to modify an object by applying multiple `Lens`es in one turn? It causes lots of new object creation if I apply them sequentially...
s
This is something that is currently not possible, but what you often want to do is make the modification a level higher. Let's say I want to adjust multiple properties of
Address
I would do that.
Copy code
Employees.employees.every.company.modify(value) { adddress ->
  address.copy(
     street= Street.name.modify(address.street, String::capitalize),
    city = address.city.capitalize()
   )
}
This is the example taken from the website. https://arrow-kt.io/docs/optics/collections_dsl/#every
🙏 1
Another option is to write a custom
Lens
that updates multiple values
🙏 1
c
Looks like this link to LensLaws 404s
I’m sorry, I meant to just put this in the channel, but was on my phone and disoriented