Home Segments Top Top Previous Next

95: Mainline

The assignment operator, =, in contrast to all the other binary operators that you have seen so far, associates from right to left. Accordingly, the expression x = y = 5 is equivalent to the expression x = (y = 5).

Fortunately, x = y = 5 does not mean (x = y) = 5, because the value of an assignment statement, such as x = y, is not a variable name. Thus, (x = y) = 5 makes no sense, and, if the assignment operator were to associate left to right, x = y = 5 would make no sense either.