Go defer
2019-03-05 本文已影响0人
JaedenKil
package main
import "fmt"
func main() {
defer fmt.Println("Defer printing")
fmt.Println("a")
fmt.Println("b")
fmt.Println("c")
fmt.Println("d")
}
Outputs:
a
b
c
d
Defer printing
package main
import "fmt"
func main() {
defer fmt.Println("Defer printing")
fmt.Println("a")
fmt.Println("b")
fmt.Println("c")
fmt.Println("d")
}
Outputs:
a
b
c
d
Defer printing