0

I am receiving the error: 'TypeError: Operator == not compatible with types bool and uint256'

my code is:

if (orderedScreening[0]/4 == orderedScreening[1]/4 == orderedScreening[2]/4 == orderedScreening[3]/4 == orderedScreening[4]/4) {
              f = true;
              }

^orderedScreening is a dynamic uint array.

I have already tried:

if (uint(orderedScreening[0]/4) == uint(orderedScreening[1]/4) == uint(orderedScreening[2]/4) == uint(orderedScreening[3]/4) == uint(orderedScreening[4]/4)) {
                  f = true;
                  }

and:

a = orderedScreening[0];
b = orderedScreening[1];
c = orderedScreening[2];
d = orderedScreening[3];
e = orderedScreening[4];

    if (a/4 == b/4 == c/4 == d/4 == e/4) {
                      f = true;
                      }

I also tested:

if (orderedScreening[0] == orderedScreening[1] == orderedScreening[2] == orderedScreening[3] == orderedScreening[4]) {
              f = true;
              }

and received the same error. How can I resolve this error?

1

This is Solidity, not Python.

Change this:

if (a/4 == b/4 == c/4 == d/4 == e/4)

To this:

if (a/4 == b/4 && b/4 == c/4 && c/4 == d/4 && d/4 == e/4)

Of course, in order to reduce gas-cost, you might want to store those intermediate results (at least b/4, c/4 and d/4) in temporary variables before using them.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.