Skip to content

Instantly share code, notes, and snippets.

@matthewcheok
Last active August 29, 2015 14:24
Show Gist options
  • Save matthewcheok/613ff45046ada1e37d63 to your computer and use it in GitHub Desktop.
Save matthewcheok/613ff45046ada1e37d63 to your computer and use it in GitHub Desktop.
Defer for Swift 1.2
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