码迷,mamicode.com
首页 > 其他好文 > 详细

learn go anonymous function

时间:2015-11-22 18:56:43      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:

package main

// 参考文档:
//     https://github.com/Unknwon/the-way-to-go_ZH_CN/blob/master/eBook/06.8.md

import "fmt"

func main() {
    f()
}

func f() {
    for i := 0; i < 4; i++ {
        g := func(i int) { fmt.Printf("%d ", i) }
        g(i)
        fmt.Printf(" -g is of type %T and has value %v\n", g, g)
    }
}

 

learn go anonymous function

标签:

原文地址:http://www.cnblogs.com/zengjfgit/p/4986363.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!