Skip to content

Instantly share code, notes, and snippets.

@plu
Created March 28, 2019 12:25
Show Gist options
  • Save plu/bb4495c758f15104a4365b2e0ce4de24 to your computer and use it in GitHub Desktop.
Save plu/bb4495c758f15104a4365b2e0ce4de24 to your computer and use it in GitHub Desktop.
import Foundation
class A {
init(completion: @escaping () -> Void) {}
}
class B {
init(a: A) {}
}
class C {
lazy var a = A { [weak self] in
guard let self = self else { return }
self.printB()
// Uncomment next line and get a compile error
// debugPrint(self.b)
}
lazy var b = B(a: self.a)
func printB() {
debugPrint(b)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment