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.