Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added definition for 'controlling expression'

Do not use the assignment operator in conditional expressions because it frequently indicates programmer error and can result in unexpected behavior.  This means that the assignment operator should not be used in the following contexts:

  • if  (controlling expression)
  • while (controlling expression)
  • do ... while (controlling expression)
  • for (second operand)
  • switch (controlling expression)
  • ?:  (first operand)
  • &&  (either operand)
  • ||  (either operand)
  • ?:  (second or third operands) where the ternary expression is used in any of these contexts

...