英文:
Zero value for funcs
问题
当你声明一个结构体 foo 时:
type foo struct {
  bar func(int) int
}
当你执行 var x foo 时,x.bar 的初始值是 nil。
英文:
Given a struct:
type foo struct {
  bar func(int) int
}
when I var x foo
what is the initial value of x.bar ?
答案1
得分: 8
根据文档:
> 未初始化的函数类型变量的值为nil。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论