If the type is too small, Ctrl+ is your friend
What is the boolean problem? I had to rewriteflag |= place[r+i][c]asflag = flag || place[r+i][c]to get it to run, and then it output "No".I think "grid [r+i][c]!=test" is always true because you're passing 1 as a parameter and the byte arrays are initialized to 0.But I'm mainly a Java programmer; maybe I don't understand Go.
Turns out that the problem is that Go, like C, has two different OR operations. One for bitwise OR of integers and a logical OR for boolean variables. I was trying to use the bitwise operator on a boolean variable, and the compiler didn't like it. Seems kind of chickenshit to me, since you can use a plus sign (+) to concatenate strings. Go is a little more particular about variable typing than C, so it seems to me they could have simply eliminated the logical operators (&& and ||) and just used the same OR and AND symbols (& and |) for logical operations as they use for bitwise ops.
Yeah, Java's the same way. "|" and "&" for integer types, "||" and "&&" for booleans. What I don't like is there's no "||=" or "&&=", but there is "|=" and "&=". That doesn't seem fair, since we use the boolean OR and AND about a hundred times more often than the integer OR and AND.
I think you've hit on it: it's unfair, and if it's unfair it must be discriminatory. We should protest. If we beat our tin cans loud enough we might be able to drum up a riot. Then we could have looting and we might even get on TV.
Post a Comment
Enter your email address:
Delivered by FeedBurner