Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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
add comment

1 Answer 1

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
1  
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
add comment

Your Answer

 
discard

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.