mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-15 10:03:44 -06:00
Add a note about operator precedence. #9169
This commit is contained in:
parent
f4a4962b21
commit
c1be0c51c6
@ -344,3 +344,14 @@ it's best to use spaces between math operators to prevent confusion or unexpecte
|
|||||||
behavior. For example, `${var.instance-count - 1}` will subtract **1** from the
|
behavior. For example, `${var.instance-count - 1}` will subtract **1** from the
|
||||||
`instance-count` variable value, while `${var.instance-count-1}` will interpolate
|
`instance-count` variable value, while `${var.instance-count-1}` will interpolate
|
||||||
the `instance-count-1` variable value.
|
the `instance-count-1` variable value.
|
||||||
|
|
||||||
|
|
||||||
|
-> **Note:** Operator precedence is not the usual one where *Multiply* (`*`),
|
||||||
|
*Divide* (`/`), and *Modulo* (`%`) have precedence over *Add* (`+`) and *Subtract* (`-`).
|
||||||
|
The operations are made in the order they appear. Parenthesis can be used to force ordering :
|
||||||
|
```
|
||||||
|
"${2 * 4 + 3 * 3}" # computes to 33
|
||||||
|
"${3 * 3 + 2 * 4}" # computes to 44
|
||||||
|
"${(2 * 4) + (3 * 3)}" # computes to 17
|
||||||
|
"${(3 * 3) + (2 * 4)}" # computes to 17
|
||||||
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user