On Mon, Sep 11, 2017 at 09:56:59AM -0700, CampNowhere wrote: > I am a C developer and am trying to pick up Go. > > My question is this. C doesn't "care" about truthfulness, it just cares > about zero and non-zero when evaluating a logical AND operator. So > something like the following in C is totally kosher: > > int a = 10; > int b = 20; > > while(a && b) > { > do_something(); > } > > However, Go requires blloean values used with the logical AND operator ... > so my necessary code change for Go implementation becomes the following: > > var a,b int = 10,20 > > for (a != 0) && (b != 0) { > do_something() > } > > Is doing things this way absolutely necessary? It seems a lot clunkier and > less elegant.
I disagree. Go approach is a lot clearer. Why 10 is true? Why -42 is true? Why a float NaN is true? That can even boild down to reading the code as plain English. "while a and b do something" is of dubious readability compared to "while a is not zero and b is not zero do something". -- 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.