Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardSwiftcopy-on-write internalsSingle-choice MCQ

Two arrays share storage via copy-on-write. The code below mutates the second one. What governs whether `b[0] = 99` triggers an actual buffer copy, and what happens to the retain count along the way?

var a = [1, 2, 3] var b = a b[0] = 99 print(a[0], b[0])