Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumSwiftweak self in closuresSingle-choice MCQ

A lazy closure property captures `self` weakly. The owner is set to `nil` after the closure is extracted but before it runs. What is printed?

class C { var value = 1 lazy var printer: () -> Void = { [weak self] in print(self?.value ?? -1) } } var c: C? = C() c?.value = 99 let p = c!.printer c = nil p()