Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Simple "or" operator question?

Asked by 9 years ago

This is a pretty basic question, but I've just been wondering. If I use an or operator to check if, for example, value a or b are true.

if a == true or b == true then
print("Done")
end

Would that print "Done" if BOTH are true at the same time? It's just something I never learned.

Thanks!

1 answer

Log in to vote
2
Answered by
Necrorave 560 Moderation Voter
9 years ago

Yes

When you look at a conditional statement, read it from left to right.

Using your example...

If the first one is true in an or statement, it has no need to check the second part of the statement. So it prints. If it were false, it would then go ahead and check the second part.

Now, if it was an and, it would check from left to right to see if both of them were true before printing. If the first one was false, then it would not bother checking the second one.

0
Ah, thanks! That's what I thought. SlickPwner 534 — 9y
Ad

Answer this question