what is or in an if statement? there is (and). is it /?
In C# it would be || (two vertical bars).
I assume it’s the same in UnityScript, but I don’t know that for sure.
ok, thanks. i bet that is what it is.
To verify, yes, it is || in unityscript.
| and || both mean or. || is generally preferable. The only time I think I’ve had to use | so far is for Selection Modes, where it only means “or” in the voltage sense, not the English sense, as far as I can gather.
Yeah, || is the “boolean or” while | is the “bitwise operator or”
Bitwise OR takes two binary inputs (like 0101 and 1001 for example) and returns a new binary output with a 1 set wherever a 1 occured in either input (0101 | 1001 = 1101) - usually it’s used like in Selection Modes to choose multiple things from possible options, with the bitwise AND () used to tell which modes are chosen:
enum Modes {
fast = 1; // 0001 in binary
hard = 2; // 0010
good = 4; // 0100
strong = 8; // 1000
}
mode = Modes.fast | Modes.good;
if ( mode Modes.fast )
Debug.Log( "Mode includes Fast!")
if ( mode Modes.good )
Debug.Log( "Mode includes Good!")
True, but it seemed clear that the OP was asking about ‘logical or’ rather than ‘bitwise/boolean or’ (hence Vicenti’s and my answer of ‘||’).
As my second link showed, | does the same thing as ||, provided the first condition is false. I like knowing this so I offered it.