这是如何解释的:<-chan int(c)?

huangapple go评论74阅读模式
英文:

How do I interpret this: <-chan int(c)?

问题

这是来自:https://go.dev/ref/spec#Conversions

&lt;-chan int(c) // 等同于 &lt;-(chan int(c))

提前感谢。

英文:

This is from: https://go.dev/ref/spec#Conversions

&lt;-chan int(c) // same as &lt;-(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, &lt;- is the receive operator and chan int is a type.

&lt;-chan int(c)  
&lt;-(chan int(c))

The expressions convert c to chan int and receive on the result of the conversion.

In next expression, &lt;- is part of the type. The &lt;- indicates that the channel is receive-only.

(&lt;-chan int)(c)

The expression converts c to a receive only channel of int.

huangapple
  • 本文由 发表于 2022年3月19日 08:34:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/71534494.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定