Triple evaluation of the expression of equality

Suppose we have 3 variables, and we need to STATE that they can either all be -1, or none of them can be -1. I wrote the following code:

x := 1;
y := 1;
z := 1;

ASSERT( (x = -1) = (y = -1) = (z = -1) );

I often write such a check, but for two variables. Surprisingly, the triple comparison is also made, but it does not work properly. For values ​​(1, 1, 1), I expect it to be true. After substitution of variable values ​​and simplification, we obtain:

ASSERT( False = False = False );

and I thought that he should evaluate True, but it is not. So how is this triple comparison evaluated?

+5
source share
2 answers

, = : . , " ". .

, , , " ". , , . , : 3+2*4 : 3+(2*4). , . , , :

((False = False) = False), , :

(True = False).

, , , , AND Assert :

ASSERT(((x = -1) = (y = -1)) and ((y = -1) = (z = -1)))

, , , AND ( SQL, ), :

Assert (
  ((x = -1) = (y = -1))
  and
  ((x = -1) = (z = -1))
);

:

Assert (
  ((x = -1) and (y = -1) and (z = -1))
  or
  ((x <> -1) and (y <> -1) and (z <> -1))
);

: 1 , , .

+8

: False = False = False (False = False) = False. False = False True, True = False, , , False.

+2

All Articles