Skip to main content
Solved

Prettify is removing parenthesis

  • September 21, 2023
  • 2 replies
  • 25 views

Forum|alt.badge.img

I am trying to use a where filter like so: 

where (a && b) || c

Prettify keeps removing the parenthesis. Doesn’t this mess with the order of operations?

Best answer by jack.shen

This shouldn’t. The logical operations can be treated similar to arithmetic operations, so it is read left to right. The only instance parenthesis is needed is when operations is done outside the left to right order. For example, there is a difference between 

A || B && C

vs. 

A || (B && C ) 

 

For more info on this, please see https://www.cs.utexas.edu/~dnp/frege/logical-operator-precedence.html

View original
Did this topic help you find an answer to your question?

  • Employee
  • September 22, 2023

This shouldn’t. The logical operations can be treated similar to arithmetic operations, so it is read left to right. The only instance parenthesis is needed is when operations is done outside the left to right order. For example, there is a difference between 

A || B && C

vs. 

A || (B && C ) 

 

For more info on this, please see https://www.cs.utexas.edu/~dnp/frege/logical-operator-precedence.html


Forum|alt.badge.img
  • Ramping Up
  • September 22, 2023

Thanks @jack.shen - that makes sense


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings