Skip to content

Instantly share code, notes, and snippets.

@Cananito
Created June 19, 2015 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cananito/f9f75076478665e7d2cc to your computer and use it in GitHub Desktop.
Save Cananito/f9f75076478665e7d2cc to your computer and use it in GitHub Desktop.
defer
func a(x: X) -> A {
defer {
print("Exiting the function")
}
if x == something() {
return A(x); // Console prints: "Exiting the function"
}
// Do more stuff
if x == other() {
return A(x); // Console prints: "Exiting the function"
}
return A(x); // Console prints: "Exiting the function"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment