[prev] 61 [next]

Assignment as Expression

Assignments can be treated as expressions returning a value

x = 5;          // returns 5

Can be useful

x = y = z = 0;  // equiv to x = (y = (z = 0))

Can be dangerous

if (x = 0)      // "test" always fails