Where would the associativity of the =
assignment operator make a difference in an expression? I thought that the associativity relates to operands that share an operator, but in the case of assignment, how would that work? A few examples that (might) be relevant are:
x = 1
x + 2 = y + 3 = z + 5
Does this just mean that, in the assignments above, we would have:
y + 3 = z + 5
Done before, for example:
x + 2 = y + 3
Or what other scenarios are there where assignment associativity 'matters' ?
x + 2 = y + 3
That's not valid C, so it's not a good example. Associativity makes a difference in cases likeint x, y = 0, z = 1; x = y = z;
. – Neela = b = c + 1
. You don't want it to meana = b
followed byb = c + 1
. – Catarrhine