3
$\begingroup$

Apparently Mathematica's syntax coloring engine believes that the second assignment in the following code excerpt (concocted for illustration purposes only) is a "Possible Unwanted Assignment" since unchecking this box in Preferences causes the red highlighting to disappear:

enter image description here

Any ideas why Mathematica should believe that this assignment is possibly unwanted? The variable b is used after all in the test conditional for the While loop whereas f and g are not.

$\endgroup$
9
$\begingroup$

This is because you are using = (the assignment operator) in the condition (not the body) of While. It is a typical beginner mistake to use = where == is meant, so Mathematica warns about this.

Since you also use several ; in the condition, it gets a little confused and only highlights one of the = signs, not all of them.

$\endgroup$
1
  • 1
    $\begingroup$ Presumably then more experienced users will want to switch off highlighting for "Possible Unwanted Assignments" (which is enabled by default). $\endgroup$ – StackExchanger May 2 '12 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.