From: AppleII717 Date: 2010-08-18T10:06:15+09:00 Subject: Re: Strange behavior of or condition in loop On Aug 17, 7:09 pm, Colin Bartlett wrote: > [Note:  parts of this message were removed to make it a legal post.] > > On Wed, Aug 18, 2010 at 12:40 AM, skim wrote: > > and/or aren't the same as &&/||.  they have lower operator precedence than > > latter. > > And to be particular for the OP's problem "and" and "or" have lower > precedence than "=" assignment. (And have the same precedence as each > other.) So >   dirty = dirty or found > is being parsed as >   (dirty = dirty) or found > But since "&&" has a higher precedence than "||" which has a higher > precedence than "=" assignment, if you replaced the "or" in the unbracketted > version by "||" you should now get the results of the bracketted version. > (At least, it worked for me just now.) > > skim: Thanks for the link - I mostly use "&&" and "||" (and sometimes also > parentheses just to be sure and to be explicit) but the explanations of the > history will probably make it easier for me to remember the precedence of > "and" and "or" when I see them being used. Thanks for the reply, explanation and link. I knew they had different precedence, but I never looked them up but figured they'd be next to each other. Never crossed my mind that assignment would have a higher precedence. A little disappointed in that I was happy to see "and" and "or" because I never liked the symbol operators. Not so much that they are bad, but one language uses & and another uses && and "and" just seems so much clearer. I hopefully will remember the next time, but may just use parentheses to keep my mind straight. Steve Alex