There's always a way to write confusing code in any language. var a,b int = 10,20
for a&b != 0 { do_something() } On Monday, September 11, 2017 at 5:07:48 PM UTC-7, Jon Jenkins 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. > -- 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.