Problem Statement
What is the difference between value semantics and reference semantics in Swift?
Explanation
Value semantics (structs) mean each instance holds its own copy of data, so modifying one does not affect others. Reference semantics (classes) mean multiple variables can refer to the same instance, so changes via one reference affect all. Recognizing this difference is key to correct design.
Practice Sets
This question appears in the following practice sets: