this is just:
issix = issix^issix ; //true xor true = false. false xor false is false. excessive if-statements slow down code execution, and xor is built into the cpu chip its very quick. assigning false over already being false costs less than compare/jump/etc of an if to avoid it. and its more concise. can use issix ^= issix; of course.
could you give an example of how to use this? let me elaborate..
lets say you have the value issix and that equals true
1 2 3 4 5 6 7
if(isSix)
isSix = false; // we need an if statement here to test if isSix == true if so set it to false
if(isSix)
isSix = isSix ^ isSix // true xor true == false BUT we still need an if statement to test if isSix is true
so my question is how do you avoid using the if statement? lets say isSix could equal true or false depending if the user inputs 6 or not, wouldn't we still need an if statement to check for this? if not how would we get rid of the if statement checking if isSix == true then setting it to false once the check is done
your code says:
if issix is true, set it to false.
which, now that I think about it, is identical to
issix = false; //if it was true, it is false now. if it was false, it is false now.
my code was overthinking it.
my code says
if it is true, make it false, if it was false, make it false. //same thing
and it just works differently.
the truth table for xor is
in in out
T T F
T F T //not possible when xor something with itself
F T T // not possible for with itself
F F F
The point is you do not need to check it. you want it to be false if it was true.
the only other option was, it was already false, and you want that unchanged. Unchanged may mean you assign it = to false, same result. Not all conditional statements are avoidable, but when dealing with Booleans, you get a lot of freebies like this one where you can.
I don't, and that is why I didn't mention it earlier. My last post was mainly a response to what adam2016 said about avoiding the if statement by using xor. If there is nothing else inside the if statement there is no reason checking the variable. Just set it to whatever value you want it to have.