Yes, The or
operator is the text equivalent of ||
.
So what you said is correct.
문제
I have seen a kind of "poetic" code in some code base. Though it looks straight forward, just want to confirm, if it's in right direction.
In a very simple form:
bool foo ();
bool bar ();
int main () {
foo() or bar(); // <--- line
}
Is the code at highlighted line as good as below snippet?
if(foo() == false)
bar();
I am aware of ,
operator where all the statements are invoked, but unsure about or
(equivalent to ||
) operator.
Testing in g++, it gives expected output.
해결책
Yes, The or
operator is the text equivalent of ||
.
So what you said is correct.
다른 팁
If the 1st condition is true
the other one isn't evaluated anymore (in ||
's case) and therefore it's as you said:
if(foo() == false)
bar();
The same thing applies to &&
when if the 1st condition is false
, the second isn't evaluated anymore.