# A condition expression should not be reduced to an assignment

**URL:** <https://discourse.processing.org/t/a-condition-expression-should-not-be-reduced-to-an-assignment/30395>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [May 31, 2021, 2:23pm UTC](https://discourse.processing.org/t/a-condition-expression-should-not-be-reduced-to-an-assignment/30395 "2021-05-31T14:23:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zang](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zang](https://discourse.processing.org/u/zang)\
**Post date:** [May 31, 2021, 2:23pm UTC](https://discourse.processing.org/t/a-condition-expression-should-not-be-reduced-to-an-assignment/30395/1 "2021-05-31T14:23:50Z")

</div>

```auto
boolean check(){
for (int j = 0; j < grid.size(); j++) {
   
      if (grid.get(j-1).visited = true
      ) {
      return true;
      }
    }
}

```

i want run some fuction after the class in a arraylist all been visited.  
then this come up"a condition expression should not be reduced to an assignment"  
i know it will return true after every check.but i really dont know what to do.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [May 31, 2021, 2:39pm UTC](https://discourse.processing.org/t/a-condition-expression-should-not-be-reduced-to-an-assignment/30395/2 "2021-05-31T14:39:00Z")

</div>

> [@zang](#):
>
> `visited = true`

Use == here for condition

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 31, 2021, 2:50pm UTC](https://discourse.processing.org/t/a-condition-expression-should-not-be-reduced-to-an-assignment/30395/3 "2021-05-31T14:50:02Z")

</div>

Hello,

Take a look here:  
_[https://docs.oracle.com/javase/tutorial/java/nutsandbolts/op2.html](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/op2.html)_

It states:

> Keep in mind that you must use " `==` ", not " `=` ", when testing if two primitive values are equal.

Also look at the Processing references:  
_[Reference / Processing.org](https://processing.org/reference/)_

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/7f910ed79c71c74d44eba54eff6ec9a83b90ed4f.png)

Have fun!

`:)`
