Skip to main content
Solved

Prettify is removing parenthesis

  • Sep 21, 2023 4:48 PM UTC
  • 2 replies
  • 138 views
  • Translate All

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

2 replies

  • Employee
  • Answer
  • Sep 22, 2023 4:59 PM UTC

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

Translate

Forum|alt.badge.img
  • Author
  • Ramping Up
  • Sep 22, 2023 5:29 PM UTC

Thanks @jack.shen - that makes sense

Translate