我是 Golang 世界的新手。我試圖理解自動(dòng)引用的概念。我對以下程序的困惑?第一個(gè)和第二個(gè)有什么區(qū)別函數(shù) main 的第一行age(20).print()二三線myAge := age(20)myAge.print()完整程序如下:package mainimport "fmt"type age uint8func (a *age) print() { fmt.Println(a)}func main() { age(20).print() // this line throws error // however, the below line works properly myAge := age(20) myAge.print()}請幫助理解這兩種方法之間的區(qū)別。我假設(shè)他們都是一樣的。
Golang 自動(dòng)引用,并不總是可以得到一個(gè)值的地址
慕碼人8056858
2022-06-13 15:36:45