Skip to content

Commit

Permalink
Corrections to Operators precedence chapter (#1393)
Browse files Browse the repository at this point in the history
* fix: move `not` operator to the proper place

* add mention of `help operators | sort-by precedence -r`

* operators presedence - rewrite

* operators precendece chatgpt rewrite
  • Loading branch information
maxim-uvarov committed May 9, 2024
1 parent 08aab5b commit aac2d69
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions book/operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ Parentheses can be used for grouping to specify evaluation order or for calling

## Order of Operations

Operations are evaluated in the following order (from highest precedence to lowest):
To understand the precedence of operations, you can run the command: `help operators | sort-by precedence -r`.

Presented in descending order of precedence, the article details the operations as follows:

- Parentheses (`()`)
- Exponentiation/Power (`**`)
Expand All @@ -50,11 +52,11 @@ Operations are evaluated in the following order (from highest precedence to lowe
- Bitwise and (`bit-and`)
- Bitwise xor (`bit-xor`)
- Bitwise or (`bit-or`)
- Logical not (`not`)
- Logical and (`and`)
- Logical xor (`xor`)
- Logical or (`or`)
- Assignment operations
- Logical not (`not`)

```
> 3 * (1 + 2)
Expand Down

0 comments on commit aac2d69

Please sign in to comment.