Skip to main content
Solved

Prettify is removing parenthesis

  • September 21, 2023
  • 2 replies
  • 37 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

2 replies

  • Employee
  • Answer
  • 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
  • Author
  • Ramping Up
  • September 22, 2023

Thanks @jack.shen - that makes sense