質問

Execution of statement

true || true ? false : true

returns false.

Shouldn't it be true since OR conditional will not execute ternary operation (right hand side part)?

役に立ちましたか?

解決

true || true ? false : true

is the same as

(true || true) ? false : true

If you meant:

true || (true ? false : true)

then you have to add the brackets yourself.

他のヒント

true || true ? false : true is like writing:

if(true || true) {
    return false;
}
return true;

Since true is... true, then the whole expression is true, so you return false.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top