Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 9 down vote accepted

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.

share|improve this answer
Presumably then more experienced users will want to switch off highlighting for "Possible Unwanted Assignments" (which is enabled by default). – StackExchanger May 2 '12 at 17:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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