I have two variables which can be either true or false. I get these by doing query on database for presence or absence of certain product ids.
Now I need to set another variable which will be true or false. it will be true value when both the variables are true or both are false. It will be false value of one is true and other is false.
at present I take care of it using if statement
if ( v1 == true && v2 == true )
result = true;
else if ( v1==false && v2 == false )
result = true;
else if ( v1 == true && v2 == false )
result = false;
else if ( v1==false && v2 == true )
result = false;
Is there exists a better way of doing this ?
I may be missing something very fundamental, but I'll give it a go:
result = ( v1 == v2 );