if ((this || that) && (that || this)).. Does that work?

Hey, I was trying to write some code to show the scoreboard when player 1 and 2 either don’t finish or finish. So far I got this:

if ((player1nf || player1Finished) && (player2nf || player2))
{
	showScoreBoard();
}

Although it didn’t give me any errors, I have a feeling the syntax of the if() isn’t correct. I was wondering how I would use ||'s along with &&'s to create something like I have in the title, if that makes any sense.

Thanks a ton.

(My answer got eaten?)

That is a totally valid if statement, but there is really no way to know if it does what you want it to do with the information given.

Logical operators follow the “inside-to-out” order of operations, just like arithmetic operators.

Consider the following:

if((a||b) && (c||d))

a||b will evaluate first. True, if either a or b is true.
We will call this A for now. c||d will evaluate next. True, if either c or d is true.
We will call this C for now.
This leaves us with

if(A && C)

which will evaluate next. True only if both A and C are true.
This means for your specific situation, that each grouping needs to have at least one true in it to drop into the if block.

Does that clear it up a bit?

That is a totally valid if statement, but there is really no way to know if it does what you want it to do with the information given.

Logical operators follow the “inside-to-out” order of operations, just like arithmetic operators.

Consider the following:

if((a||b) && (c||d))

a||b will evaluate first. True, if either a or b is true.
We will call this A for now.
c||d will evaluate next. True, if either c or d is true.
We will call this C for now.
This leaves us with

if(A && C)

which will evaluate next. True only if both A and C are true.
This means for your specific situation, that each grouping needs to have at least one true in it to drop into the if block.

Does that clear it up a bit?

simply use …

if(player1finished || player2finished)

Red