mardi 28 juin 2016

If statement with || and multiple &&

I have booleans A, B, C, D set to false.

I have following code if (A && B || C && D) {Debug.i("Check", "stars")}

When will I get "stars" message?

  1. When A and B OR C and D set to true.
  2. When A, B/C, D set to true

=============================

ANSWER

A && B || C && D

should be treated as

(A && B) || (C && D)

Aucun commentaire:

Enregistrer un commentaire