Might be overkill, but if you have a lot of use cases like this you could look at #arrow optics
Sam
08/23/2022, 7:44 AM
There’s also https://youtrack.jetbrains.com/issue/KT-44653 for the proposed “copy var” syntax but it’s gone a bit quiet, and I also don’t know if it would support your use case of indexing into a list
Sam
08/23/2022, 7:49 AM
As far as the current language capabilities, the best I can think of is to use a helper function something like this: