Last active
August 29, 2015 14:24
-
-
Save matthewcheok/613ff45046ada1e37d63 to your computer and use it in GitHub Desktop.
Defer for Swift 1.2
This file contains hidden or 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
class Deferrable { | |
let closure: ()->Void | |
init(closure: ()->Void) { | |
self.closure = closure | |
} | |
deinit { | |
closure() | |
} | |
} | |
func test() { | |
print("Test 1") | |
Deferrable { | |
print("Test 2") | |
} | |
print("Test 3") | |
} | |
test() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment