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

Two `[Int]` arrays share a buffer via copy-on-write. The code below runs `b.withUnsafeMutableBufferPointer { $0[0] = 99 }`. What does the standard library guarantee happens before the closure body executes, and what does `a` print?

var a = [1, 2, 3] var b = a b.withUnsafeMutableBufferPointer { buf in buf[0] = 99 } print(a[0])