Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【第 57 天】下面哪一行代码会 panic,请说明原因? #80

Open
Seekload opened this issue Oct 30, 2019 · 2 comments
Open

Comments

@Seekload
Copy link
Owner

package main

func main() {
  var x interface{}
  var y interface{} = []int{3, 5}
  _ = x == x
  _ = x == y
  _ = y == y
}
@tony2051
Copy link

tony2051 commented Nov 5, 2019

_ = y == y x的值为nil, 而 y 是一个int数组,数组和数组不能==比较,但可以判断数组是否等于 nil

@Seekload
Copy link
Owner Author

Seekload commented Nov 7, 2019

_ = y == y x的值为nil, 而 y 是一个int数组,数组和数组不能==比较,但可以判断数组是否等于 nil

[]int{3, 5} 是切片,属于不能比较类型,数组是可以比较的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants