Created
June 18, 2021 22:24
-
-
Save mhijack/4a273233c6ce322ad75ef6b12c067246 to your computer and use it in GitHub Desktop.
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
func myAutoclosure(auto: @autoclosure @escaping () -> Void) -> () -> Void { | |
return auto | |
} | |
let haha: () -> Void = myAutoclosure(auto: print("haha")) // autoclosure will not be called here even though it looks like we are calling it right away | |
print("haha should not be called yet") | |
haha() | |
print("haha should be called") | |
// haha should not be called yet | |
// haha | |
// haha should be called |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment