question regarding BOOLEAN operator ‘|’ and ‘||’. The only difference I can find between these two operators is; when using ‘||’ the right side of the expression will not be evaluated if the left side is true.
Outside of person preference why would one use ‘|’ over ‘||’ for boolean testing?
if(true | false)
{
do something
}
vs
if (true || false)
{
do something
}
It’s primarily an issue if the operation has side effects:
Consider the following:
Because the
MoveNextoperations cause side effects it may be important for both sides of the|to be executed regardless of whether the first is true.