https://kotlinlang.org logo
Title
d

dave08

05/24/2023, 10:30 AM
I'd suppose so, but asking just in case... does
copy { }
make another instance of the class on each
set
or
transform
called, or does it somehow aggregate the changes and make one copy in the end?
a

Alejandro Serrano Mena

05/25/2023, 7:15 AM
right now it creates a new copy each time
we have plans to make it more clever using a compiler plug-in, but right now we’re scarce in time
d

dave08

05/25/2023, 8:52 AM
Oh.. I thought I understood from your video that it was better than kopykat in that sense... but nice to hear there's plans for it, thanks!
a

Alejandro Serrano Mena

05/25/2023, 7:50 PM
it’s better because it doesn’t copy to a mutable variable and then back again, it only creates one copy
so if you have a lot of modifications, KopyKat is better (one big copy at the beginning, one at the end), whereas Optics are better for a few changes