Last active
October 23, 2023 07:51
-
-
Save keisukeYamagishi/136680e4cbac1d6b954485e9c59f5791 to your computer and use it in GitHub Desktop.
A reference method for 'self' that doesn't use either weak references or non-owning references
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
class Closures { | |
let memberVariable = "member" | |
let memberVariable2 = "member2" | |
func execute() { | |
closures { [self] in | |
print(memberVariable) | |
print(memberVariable2) | |
} | |
} | |
private func closures(_ handler: (() -> Void)) { | |
handler() | |
} | |
} | |
let c = Closures() | |
c.execute() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment