英文:
How do I interpret this: <-chan int(c)?
问题
这是来自:https://go.dev/ref/spec#Conversions
<-chan int(c) // 等同于 <-(chan int(c))
提前感谢。
英文:
This is from: https://go.dev/ref/spec#Conversions
<-chan int(c) // same as <-(chan int(c))
Thanks in advance
答案1
得分: 1
在以下表达式中,<- 是接收操作符,chan int 是一种类型。
<-chan int(c)
<-(chan int(c))
这些表达式将 c 转换为 chan int 并在转换结果上进行接收操作。
在下一个表达式中,<- 是类型的一部分。<- 表示该通道是只接收的。
(<-chan int)(c)
该表达式将 c 转换为一个只接收 int 类型的通道。
英文:
In the following expressions, <- is the receive operator and chan int is a type.
<-chan int(c)
<-(chan int(c))
The expressions convert c to chan int and receive on the result of the conversion.
In next expression, <- is part of the type. The <- indicates that the channel is receive-only.
(<-chan int)(c)
The expression converts c to a receive only channel of int.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论