FAQ
Hello,

I am trying to find out what is a nil channel. I mean, from the spec I can
understand it's semantic, but I am not sure how to create it. I think I
need to change existing (closed) channel to nil channel to stop consuming
nil values in a select statement, but I am unable to find how to do it.

So what is the trick to create a nil channel? This does not work:

ch = make(chan xyz)
close(ch)
ch = make(chan nil)

Thanks!

--

Search Discussions

  • Lukáš Zapletal at Jan 2, 2013 at 9:42 pm
    Oh my :-)

    ch = nil

    Ok, time to go to bed. I apologize for this, was not obvious for me.

    LZ
    On Wednesday, January 2, 2013 10:40:45 PM UTC+1, Lukáš Zapletal wrote:

    Hello,

    I am trying to find out what is a nil channel. I mean, from the spec I can
    understand it's semantic, but I am not sure how to create it. I think I
    need to change existing (closed) channel to nil channel to stop consuming
    nil values in a select statement, but I am unable to find how to do it.

    So what is the trick to create a nil channel? This does not work:

    ch = make(chan xyz)
    close(ch)
    ch = make(chan nil)

    Thanks!
    --
  • Kevin Malachowski at Jan 3, 2013 at 2:38 am
    Don't you love figuring out the answer just a few minutes after asking the public? If its any consolation I had the same confusion initially when learning the specifics of channels.

    --
  • Dustin Sallings at Jan 3, 2013 at 10:45 pm

    Lukáš Zapletal writes:

    ch = make(chan xyz)
    var ch chan xyz

    --
    dustin

    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJan 2, '13 at 9:42p
activeJan 3, '13 at 10:45p
posts4
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase