1. 首页
  2. 主题
  3. Go问与答

下面的代码 输出为什么是 false

miss201 · · 966 次点击
package main import ( "fmt" ) type S struct { a, b, c string } func main() { x := interface{}(&S{"a", "b", "c"}) y := interface{}(&S{"a", "b", "c"}) //x := &S{"a", "b", "c"} //y := &S{"a", "b", "c"} fmt.Println(x == y) }
如上图,你的这个例子type是&S,但data是两个指针内容不一致。可以看看下面链接的内容。 https://research.swtch.com/interfaces
#2
更多评论
![image.png](https://static.studygolang.com/180719/474a144be547a6a4b876985fd532c4b1.png)
#1

用户登录

没有账号?注册

今日阅读排行

    加载中

一周阅读排行

    加载中