Intermediate
Swift
Q51 / 100
What is copy-on-write (COW) in Swift?
Correct! Well done.
Incorrect.
The correct answer is B) An optimization where value types (like Array) share storage until a mutation occurs, at which point a unique copy is made
B
Correct Answer
An optimization where value types (like Array) share storage until a mutation occurs, at which point a unique copy is made
Explanation
var b = a; b.append(1) — only when b is actually mutated does Swift create a new storage copy. This makes large-array assignment cheap.
Progress
51/100