Go defer 02

作者: JaedenKil | 来源:发表于2019-03-05 15:17 被阅读0次
    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.

    相关文章

      网友评论

        本文标题:Go defer 02

        本文链接:https://www.haomeiwen.com/subject/itqouqtx.html