Skip to content

Instantly share code, notes, and snippets.

@es-kumagai
Created July 23, 2015 10:27
Show Gist options
  • Save es-kumagai/0f4a21c49389ea008c94 to your computer and use it in GitHub Desktop.
Save es-kumagai/0f4a21c49389ea008c94 to your computer and use it in GitHub Desktop.
もしかして Swift の大域はスコープという概念がない、もしくは特殊っぽい? #CodePiece
// 大域だと先に 1 が表示される
defer {
print(1)
}
print(2)
// 関数だと先に 2 が表示される
func test() {
defer {
print(1)
}
print(2)
}
test()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment