我以爲我理解了Go的類和方法接收器,但顯然不是。他們一般工作直觀,但這裏的地方使用一個似乎引起「未定義:跆拳道」的例子錯誤:爲什麼指定Method Receiver有時會觸發'未定義'錯誤?
package main
type Writeable struct {
seq int
}
func (w Writeable) Wtf() { // causes a compile error
//func Wtf() { // if you use this instead, it works
}
func Write() {
Wtf() // this is the line that the compiler complains about
}
func main() {
}
我現在用的是過去的一個月左右,並LiteIDE內golang下載的編譯器。請解釋!
回想起來,這些事情總是顯而易見,非常感謝。 – GregT