Go 支持函数内部嵌套结构,但除了 lambda 之外没有嵌套函数,这是否意味着无法在函数内部定义嵌套类?
func f() {
// nested struct Cls inside f
type Cls struct {
...
}
// try bounding foo to Cls but fail
func (c *Cls) foo() {
...
}
}
因此,类在功能内部被削弱感觉有点奇怪。
任何提示?
翻过高山走不出你
30秒到达战场
随时随地看视频慕课网APP
相关分类