0

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.

  • 1
    Does 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

0 Answers0