You can use these shortcuts for better readability when you have lots of if-else statements
A = B == CThis is read as:
If B = C then A is true, else A is false
The statement above is the same as this if-else statement:
if(B == C){The other one has a more familiar form than the previous:
A = true;
} else {
A = false;
}
A = A ? B : CThis is read as:
If A is true it will take the value of B, If A is false else A will be C.
The statement above is the same as this if-else statement:
if(A == true){Note: A,B, and C should return a boolean value.
A = B;
} else {
A = C;
}
0 comments: