Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumSwiftretain cycles and capture listsSingle-choice MCQ

What is the result of capturing a mutable local variable in two closures without a capture list?

func makeCounters() -> (() -> Int, () -> Void) { var x = 0 let read = { x } let bump = { x += 1 } return (read, bump) } let (read, bump) = makeCounters() bump() bump() print(read())