I am trying to store a boolean value into a variable with the additional property that the value changes each time the variable is called.
In = var Out = True In = var Out = False
My approach was
var := If[ TrueQ[var], var = False, var = True ]
but this is not working. My guess is that is recurring when is calling TrueQ[var]; if this is the case I don't understand why I don't have a recursion limit error.
How can I make my code work?