Skip to content

Commit baa8b69

Browse files
CopilotBillWagner
andauthored
Clarify operator precedence terminology and improve examples in Visual Basic documentation (#48257)
* Initial plan * Clarify operator precedence terminology and improve examples Co-authored-by: BillWagner <[email protected]> * Add numerical indices to precedence order headings for clarity Co-authored-by: BillWagner <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: BillWagner <[email protected]>
1 parent a2732bb commit baa8b69

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

docs/visual-basic/language-reference/operators/operator-precedence.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ When several operations occur in an expression, each part is evaluated and resol
2424

2525
When expressions contain operators from more than one category, they are evaluated according to the following rules:
2626

27-
- The arithmetic and concatenation operators have the order of precedence described in the following section, and all have greater precedence than the comparison, logical, and bitwise operators.
27+
- The arithmetic and concatenation operators have the order of precedence described in the following section, and all have greater precedence than the comparison, logical, and bitwise operators. Higher precedence means these operators are evaluated first.
2828

2929
- All comparison operators have equal precedence, and all have greater precedence than the logical and bitwise operators, but lower precedence than the arithmetic and concatenation operators.
3030

@@ -34,13 +34,13 @@ When several operations occur in an expression, each part is evaluated and resol
3434

3535
## Precedence Order
3636

37-
Operators are evaluated in the following order of precedence:
37+
Operators are evaluated in the following order of precedence. Operators listed first have higher precedence and are evaluated before operators listed later:
3838

39-
### Await Operator
39+
### 1. Await Operator
4040

4141
Await
4242

43-
### Arithmetic and Concatenation Operators
43+
### 2. Arithmetic and Concatenation Operators
4444

4545
Exponentiation (`^`)
4646

@@ -58,11 +58,11 @@ When several operations occur in an expression, each part is evaluated and resol
5858

5959
Arithmetic bit shift (`<<`, `>>`)
6060

61-
### Comparison Operators
61+
### 3. Comparison Operators
6262

6363
All comparison operators (`=`, `<>`, `<`, `<=`, `>`, `>=`, `Is`, `IsNot`, `Like`, `TypeOf`...`Is`)
6464

65-
### Logical and Bitwise Operators
65+
### 4. Logical and Bitwise Operators
6666

6767
Negation (`Not`)
6868

@@ -108,7 +108,9 @@ e = 1.0
108108
f = a - b + c / d * e
109109
' The preceding line sets f to 7.0. Because of natural operator
110110
' precedence and associativity, it is exactly equivalent to the
111-
' following line.
111+
' following line. Division and multiplication (/, *) have higher
112+
' precedence than addition and subtraction (+, -), so c / d * e
113+
' is evaluated first, then the addition and subtraction from left to right.
112114
f = (a - b) + ((c / d) * e)
113115
' The following line overrides the natural operator precedence
114116
' and left associativity.

0 commit comments

Comments
 (0)