Echoing Nigel. Here's some C:
if ((tempNode->parent) && (tempNode->arcToParent->flow))
{
   // do some work
}

Here's some Go:
if tempNode.parent != nil && tempNode.arcToParent.flow != 0 {
   // do some work
}

Certainly the Go code is easier to understand; especially if you're asked 
to support someone else's code.

Source: https://github.com/clbanning/pseudo.

On Saturday, May 20, 2017 at 9:01:46 AM UTC-6, Brian Candler wrote:
>
> 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