As far as I understand when I call a struct's method declared as mutating, the whole structure is reconstructed with the new values. My question is: Isn't this something expensive in terms of performance? should we avoid it as much as possible. Why don't just use clases that is mutating.
Asked
Active
Viewed 37 times
0
-
1Does this answer your question? https://stackoverflow.com/a/42421099/3141234 β Alexander May 04 '20 at 20:25
-
No, a whole new structure is not instantiated. No, itβs not expensive. No, this is not a good reason to use classes. β Rob May 04 '20 at 21:02
-
Not directly related, but might be an interesting read for you https://medium.com/commencis/stop-using-structs-e1be9a86376f β emrepun May 04 '20 at 21:33