golan operator

133 views
Skip to first unread message

Anjana Prabhakar

unread,
Aug 3, 2020, 12:55:58 AM8/3/20
to golang-nuts
Dear All,

Can someone help me understand the syntax
a <- b
b := <-a
Thanks for the help.

Regards,
Anjana 

Kurtis Rader

unread,
Aug 3, 2020, 1:10:56 AM8/3/20
to Anjana Prabhakar, golang-nuts
On Sun, Aug 2, 2020 at 9:56 PM Anjana Prabhakar <prabhaka...@gmail.com> wrote:
Dear All,

Can someone help me understand the syntax
a <- b
b := <-a

The "<-" operator is the channel receive operator. See https://golang.org/ref/spec#Channel_types and https://golang.org/ref/spec#Receive_operator. Those statements are retrieving the next value from a channel and assigning it to a variable. I recommend working through every example at https://tour.golang.org/. That is the easiest, quickest, way to gain a basic understanding of the Go language. Your question is addressed by the concurrency section of the tour: https://tour.golang.org/concurrency/1.

--
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

PH2015014 Anjana Prabhakar

unread,
Aug 9, 2020, 10:26:53 AM8/9/20
to Kurtis Rader, golang-nuts

Thank you Kurtis. It was a great help.

 

Sent from Mail for Windows 10

Reply all
Reply to author
Forward
0 new messages