Skip to content

Commit 296ce59

Browse files
authored
Merge pull request hashicorp#9624 from rottenbytes/TF-9169
Add a note about operator precedence. hashicorp#9169
2 parents aad3941 + c1be0c5 commit 296ce59

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

website/source/docs/configuration/interpolation.html.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,3 +353,14 @@ it's best to use spaces between math operators to prevent confusion or unexpecte
353353
behavior. For example, `${var.instance-count - 1}` will subtract **1** from the
354354
`instance-count` variable value, while `${var.instance-count-1}` will interpolate
355355
the `instance-count-1` variable value.
356+
357+
358+
-> **Note:** Operator precedence is not the usual one where *Multiply* (`*`),
359+
*Divide* (`/`), and *Modulo* (`%`) have precedence over *Add* (`+`) and *Subtract* (`-`).
360+
The operations are made in the order they appear. Parenthesis can be used to force ordering :
361+
```
362+
"${2 * 4 + 3 * 3}" # computes to 33
363+
"${3 * 3 + 2 * 4}" # computes to 44
364+
"${(2 * 4) + (3 * 3)}" # computes to 17
365+
"${(3 * 3) + (2 * 4)}" # computes to 17
366+
```

0 commit comments

Comments
 (0)