package main
import "fmt"
func main() {
for i := 1; i <= 5; i++ {
defer fmt.Println(i)
}
fmt.Println("Outside the loop")
}
Output:
Outside the loop
5
4
3
2
1
package main
import "fmt"
func main() {
for i := 1; i <= 5; i++ {
defer fmt.Println(i)
}
fmt.Println("Outside the loop")
}
Output:
Outside the loop
5
4
3
2
1
本文标题:Go defer 02
本文链接:https://www.haomeiwen.com/subject/itqouqtx.html
网友评论