✓ Accepted answer
Hello,
local A,B = 0,1
if A == 1 and B == 1 then
print("true AND "..A,B)
else
print("FAIL AND "..A,B)
end
OUTPUT : FAIL AND 0 1
local A,B = 0,1
if A == 1 or B == 1 then
print("true OR "..A,B)
else
print("FAIL OR "..A,B)
end
OUTPUT : true OR 0 1
The and operator will check if both statements are matching the desired value.
In this case if A == 1 and B == 1 then , but A is 0 and B is 1 .
So, the statement results in a false and prints the above.
The or operator will check if atleast one statement is matching the desired value.
In this case if A == 1 or B == 1 then , A is 0 so the first statement is false, but B is 1.
So, it is indeed a true statement as atleast one statement is true.
Therefore , it will give the above output.
Thank you for reading.
Feel free to ask any questions.
1 comment
Thanks, but I knew about the rest, I only needed help with the understandment of 'And'