Go

Go defer 02

2019-03-05  本文已影响0人  JaedenKil
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
Last in first out.
上一篇下一篇

猜你喜欢

热点阅读