Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require parens around mixed boolean expressions #6

Open
kastermester opened this issue May 9, 2017 · 0 comments
Open

Require parens around mixed boolean expressions #6

kastermester opened this issue May 9, 2017 · 0 comments
Labels

Comments

@kastermester
Copy link
Member

To avoid misunderstandings when writing code, and aid readability when reading code, the following expressions:

(exprA || exprB && exprC);
(exprA && exprB || exprC);

Must be written as:

(exprA || (exprB && exprC));
((exprA && exprB) || exprC);

Obviously it is also valid to write them as:

((exprA || exprB) && exprC);
(exprA && (exprB || exprC));

The idea here is to avoid any possible confusion around precedens in the operators.

Other cases that needs taken care of are most welcome additions to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant