I believe the answer is a simple Yes, it is similar
Using your example
Anything inside the parenthesis will be considered one condition. You are clumping these conditions together. A simple comparison would be this (2+2) = (4)
Same goes for bools. (true and false) = false while (false or true) = true
Lets say we have the following:
if (a and b) or c then
end
What this will do is check the first part of the conditional statement a and b. As you may already know, it will check to see if a and b are both true.
Although, because they are placed inside of parenthesis, they are considered a single condition.
If that turns out to be true, it will not bother checking the next condition because it has already succeeded regarding the or
Another example:
if (a and b) or (c or d) then
end
This gets a bit more tricky. It will check if a and b are both true. Either way, it will continue to the next condition because of the or
It would then check if c or d are true. If either of them are, the code will run through the statement as if true, regardless of what a and b resulted in.
A more numerical example:
if ((math.random(10) - 5) + 1 < (math.random(10) - 5) + 1) then
end
This will first follow PEMDAS and subtract 5 from the random number generated. Then it will add 1 to it afterwards. Which it would then compare to the same condition after the <and repeat the same process.
Does that answer any questions you had? If not, please let me know.
EDIT: To answer your comment, Yes. It will check things outside the parenthesis as long as the rest of the conditional allows it.
(a or b) and c will still check if c is true too because the statement relies on both conditions being true. Hence the and
Parenthesis are just a way to manipulate the data within the statements, but it will always go check the rest (Unless its an or of course)
PS: I know this is a rather hard topic to explain, was this ideal?
1 comment
if a or b or c or d and e. This works