Go语言爱好者周刊:第 85 期

polaris · · 7177 次点击
## [Golang通道类型定义](https://golang.org/ref/spec#Channel_types) > The <- operator associates with the leftmost chan possible: > ```golang chan<- chan int // same as chan<- (chan int) chan<- <-chan int // same as chan<- (<-chan int) <-chan <-chan int // same as <-chan (<-chan int) chan (<-chan int) ``` 所以题目中: > ```golang var x chan<-chan error // nil 类型:chan<- (chan error) var y chan(<-chan error) // nil 类型:chan (<-chan error) ``` ## [Golang比较规范](https://golang.org/ref/spec#Comparison_operators) > In any comparison, the first operand must be assignable to the type of the second operand, or vice versa. ## [Golang可赋值规范](https://golang.org/ref/spec#Assignability) 结论: 类型不同,且不可相互赋值,无法进行比较。 【C:无法编译】
#1