Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumSwiftescaping vs non-escaping closuresSingle-choice MCQ

Why is `self.` required when referencing `value` inside the escaping closure but not strictly inside the non-escaping one (pre-implicit-self relaxation)?

final class Box { var value = 0 func nonescaping(_ f: () -> Int) { _ = f() } func escaping(_ f: @escaping () -> Int) {} func go() { nonescaping { value } // no self. needed escaping { self.value } // self. required } }