除了它们不被认为是等效的之外,这两个结构之间有什么区别?
package main
func main() {}
func f1(s struct{a int;b int}) { f2(s) }
func f2(s struct{b int;a int}) {}
$ go run a.go
# command-line-arguments
./a.go:3: cannot use s (type struct { a int; b int }) as type struct { b int; a int } in argument to f2
注意:这确实编译:
package main
func main() {}
func f1(s struct{a int;b int}) { f2(s) }
func f2(s struct{a int;b int}) {}
ITMISS
慕侠2389804
临摹微笑
相关分类