Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Using the assignment operator in these conditional expressions is permissible if it is not the controlling expression, as shown in the following compliant example:

Code Block
bgColor#ccccff
String line;
BufferedReader reader = // initialize
while ((line = reader.readLine()) != null) {
  // ... work with line
}

Related Guidelines

ISO/IEC TR 24772:2010

"Likely Incorrect Expression [KOA]"

MITRE CWE

CWE ID 480, "Use of Incorrect Operator"

...