# X=y=z doesn't return error

**URL:** <https://discourse.processing.org/t/x-y-z-doesnt-return-error/33912>\
**Category:** Beginners\
**Created:** [December 4, 2021, 8:06am UTC](https://discourse.processing.org/t/x-y-z-doesnt-return-error/33912 "2021-12-04T08:06:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [December 4, 2021, 8:06am UTC](https://discourse.processing.org/t/x-y-z-doesnt-return-error/33912/1 "2021-12-04T08:06:32Z")

</div>

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/d2d8224fadbfcdade571eda33ccce8507213ef93.png)  
I was making a simple project, when I mistyped the code and ended with this. What does it do? Why doesn’t it return an error? Why is ON underlined in yellow? Doesn’t it change? Or is it because it is not used later in the code?

Anyway, I am confused. Can somebody please explain?

---

<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:** [December 4, 2021, 8:28am UTC](https://discourse.processing.org/t/x-y-z-doesnt-return-error/33912/2 "2021-12-04T08:28:48Z")

</div>

Hello,

See:  
[Operator Precedence](https://introcs.cs.princeton.edu/java/11precedence/) \< See _Associativity_

> ## Associativity.
> 
> When an expression has two operators with the same precedence, the expression is evaluated according to its _associativity_ . For example x = y = z = 17 is treated as x = (y = (z = 17)), leaving all three variables with the value 17, since the = operator has right-to-left associativity (and an assignment statement evaluates to the value on the right hand side).

I did not get an _underline_:

```auto
boolean test [][] = new boolean [2][2];

void setup() 
	{
  //int i = 0;
  //int j = 0;
  //boolean on = test[i][j] = random(1)<0.5;
  
  for(int i = 0; i<2; i++) for(int j = 0; j<2; j++) {
    boolean on = test[i][j] = random(1)<0.5;
    println (on);
    }
  }

```

> [@CodeMasterX](#):
>
> Or is it because it is not used later in the code?

_[Variable Scope / Examples / Processing.org](https://processing.org/examples/variablescope.html)_

`:)`

---

<div class="post-metadata">

**Author:** ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)\
**Post date:** [December 4, 2021, 8:28am UTC](https://discourse.processing.org/t/x-y-z-doesnt-return-error/33912/3 "2021-12-04T08:28:57Z")

</div>

In some programming languages, the assignment command returns the value that was assigned. This can be useful if you want to assign several variables to the same value at the same time.

Thus,

```auto
x = y = z;

```

Is the same as

```auto
y = z;
x = y;

```

You should experiment with this in your language of choice.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [December 4, 2021, 9:31am UTC](https://discourse.processing.org/t/x-y-z-doesnt-return-error/33912/4 "2021-12-04T09:31:05Z")

</div>

> [@TfGuy44](#):
>
> In some programming languages, the assignment command returns the value that was assigned.

I wouldn’t say some. Apart from Python, I’d say in mostly C-derived languages we can have assignments almost anywhere.

BtW, the assignment symbol isn’t a command but an operator (except Python):

> **[Assignment (=) - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Assignment)**
>
> The assignment (=) operator is used to assign a value to a variable or property. The assignment expression itself has a value, which is the assigned value. This allows multiple assignments to be chained in order to assign a single value to multiple...

B/c it’s an operator, we can use it not only in chainable assignments like in here:  
[studio.ProcessingTogether.com/sp/pad/export/ro.9lMOG-RZX8JDk](http://studio.ProcessingTogether.com/sp/pad/export/ro.9lMOG-RZX8JDk)

```auto
final float x = points[i].x += EASE * .5 * xdist;
final float y = points[i].y += EASE * .5 * ydist;

```

But also as a conditional test in `if ()` blocks:  
[studio.ProcessingTogether.com/sp/pad/export/ro.9V7R1wu55fOiN](http://studio.ProcessingTogether.com/sp/pad/export/ro.9V7R1wu55fOiN)

```auto
if ( isDead = isHit() ) --aliveNum;

```

```auto
void update() {
  if ( (x += vx) < rw | x > width - rw ) vx *= -1;
  if ( (y += vy) < rh | y > height - rh ) vy *= -1;
}

```

We can even invoke the value assigned as a function and pass it as an argument afterwards:

```auto
Knot(final PVector vec) {
  c = color((v = vec).mag(), 255, 255);
}

```

> **[3D Knot (Java) - GoToLoop - OpenProcessing](https://openprocessing.org/sketch/608725)**
>
> https://YouTu.be/r6YMKr1X0VA

P.S.: Chain-assignments are evaluated from right to left btW.
