英文:
What does `(<-chan Delivery)(deliveries)` do?
问题
我找到了这行代码:
return (<-chan Delivery)(deliveries), nil
它的作用是什么?为什么有双括号?
英文:
I found this line:
return (<-chan Delivery)(deliveries), nil
https://github.com/streadway/amqp/blob/master/channel.go#L1089
What does it do? Why the double parentheses?
答案1
得分: 9
这是一个类型转换。在你的情况下,它将chan Delivery(双向的Delivery值通道)转换为<-chan Delivery(只接收Delivery值的通道)。
英文:
It's a type conversion. In your case, it converts chan Delivery (two-way channel of Delivery values) to <-chan Delivery (receive-only channel of Delivery values).
答案2
得分: 4
这是一个类型转换。将deliveries转换为只读通道。
英文:
It is a type conversion. Returns deliveries as a read-only channel.
答案3
得分: 4
这是从双向通道转换为只发送通道的类型转换,如果你提供它,可以省略。转换将隐式完成。
英文:
Its a type conversion from two-way channel to send-only channel and in case you provide it can be omitted. Conversion would be done implicitly.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论