FAQ
Hello,

I had case when I wanted to receive msg and and send message from inchan to
outchan in for-select. What I have did is following.

for {
select {
case msg = <-inchan:
case <-exitc:
exit = true
}

if exit {
break
}

select {
case outchan <- msg:
case <-exitc:
exit = true
}

if exit {
break
}
}

Any better way of doing it? *If language supports* then what I want can be
done as following, if inchan is ready to send and outchan ready to receive
then only it succeed.

for {
select {
case outchan <- inchan:
case <-exitc:
exit = true
}

if exit {
break
}
}

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 11 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 29, '13 at 11:31a
activeNov 29, '13 at 12:30p
posts11
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase