问题场景
今天尝试对指针类型进行封装并对外提供判空方法(类似Java8的Optional)的时候,发现Golang要求接收器的基类型不能是指针类型或者接口类型。
等价代码如下:
type Integer *intfunc (i Integer) isNil() bool {if i == nil {return true} else {return false}}
Golang文档中对此的说明:https://golang.org/ref/spec#Method_declarations(或者http://docs.studygolang.com/ref/spec#Method_declarations)
解决方法
暂无
