I tried googling and searching the FAQ, but I didn't find the answer to 
this question.

Coming from a C background, I see a lot of Go code like this:

if err != nil {
    ...
}

And I wonder why the language designers decided not to allow this:

if err {
    ...
}

especially since Go has a well-defined notion of "zero value" which could 
be treated as "false" in this context.

Clearly it's a matter of design preference and idiom, and some languages 
have chosen the other path. Python has a similar concept of zero values 
(e.g. empty strings and empty arrays are false); Ruby treats all values as 
true, apart from false and nil.

I expect this has been discussed before, so happy to receive any pointers.

Thanks,

Brian.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to