Last active
August 29, 2015 14:03
-
-
Save YuheiNakasaka/1f84789657239078fe42 to your computer and use it in GitHub Desktop.
deferを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
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
fmt.Println("スタート!") | |
defer fmt.Println("defer 1つめ") | |
defer fmt.Println("defer 2つめ") | |
fmt.Println("フィニッシュ!") | |
/* | |
下のdefer文から実行される | |
# go run defer_sample.go | |
スタート! | |
フィニッシュ! | |
defer 2つめ | |
defer 1つめ | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment