Hi, it was mentioned that when we are checking to see if a variable is value A or Value B, we shouldn't do
if (variable == value A) {
//Do something
}else{
// Assuming that the variable is value B and do something.
}
I get that the rationale for doing this is because the variable can hold more than 2 values thus we cant assume that if it isnt value A, it would be value B.
However, for my case above , i am checking the value of a boolean thus can i use the if statement to check if the boolean is true and for the else statement, i would assume it is false since it can only take on two values.
Hi, it was mentioned that when we are checking to see if a variable is value A or Value B, we shouldn't do if (variable == value A) { //Do something }else{ // Assuming that the variable is value B and do something. } I get that the rationale for doing this is because the variable can hold more than 2 values thus we cant assume that if it isnt value A, it would be value B.
However, for my case above , i am checking the value of a boolean thus can i use the if statement to check if the boolean is true and for the else statement, i would assume it is false since it can only take on two values.