FAQ

On Wed, Mar 2, 2016 at 2:18 PM, Sam Whited wrote:
I'm assuming that by "nil" channel you mean one that has nothing in it?
Nevermind, just realized that you meant eg.

var c chan int;

this is different, but still useful.

Eg. imagine you do a select on a nil channel:

     func dowork(c chan int) {
         select {
             case <-c
                 // Do some work if not nil
            default:
                return // Don't do anything:
         }
     }

You don't have to do a nil check on this function, the correct thing
just happens.

—Sam

--
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/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

People

Translate

site design / logo © 2022 Grokbase