in reply to || vs or

Should I start using 'or' consistently?

Consistency is always a good thing. But if you mean "exclusively", the answer should be no. 'or' and || have subtly different meanings (as others have pointed out; it's a precedence thing), and thus, have different uses. Try to be consistent on when and how you use them, but don't subject your code to contortions just to enforce exclusivity.


Dave

Replies are listed 'Best First'.
Re^2: || vs or
by TimToady (Parson) on May 16, 2007 at 21:14 UTC
    To the first approximation, use || when you want to find the first true value in a list of values, and use or when you want to do logic on the results of expressions. The or precedence level was added specifically in order to do logic on the results of list operators without requiring them to be turned into function calls with parens. Hence or is generally used as control flow between "almost statements", and typically reads better for logic within a boolean context too. The || operator is mostly relegated to picking fallback or default values, and in fact much of that usage will end up using // in the future instead.