I will summarize how to use logical operators when you want to overlap conditions in if statements that you learned today.
&& → and Example
if a && b
#processing
end
When both a and b are true, the process is executed.
||→ or Example
if a || b
#processing
end
If either a or b is true, the process is executed.
!a
true and false are opposite.
Example
if !a
#processing
end
If a is really false, the process is executed. (Because false changes to true)
Simply put, use () to tie up a unit.
Example
if ( a && b ) || ( !a && !b )
#processing
end
||Therefore, if the left side or the right side is true, the process is executed. If the left side is "a and b is true", the left side as a whole becomes true. If the right side is "a and b are really false", the right side as a whole becomes true. The point is that if a and b match with true or false, the process will be executed. </ font>
It's like what I did in high school number A ...
Recommended Posts