You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/bicep/variables.md
+13-24Lines changed: 13 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,11 +79,21 @@ The preceding example returns a value like the following:
79
79
80
80
### Typed variables
81
81
82
-
Bicep supports **typed variables**, where you explicitly declare the data type of a variable to ensure type safety and improve code clarity. By specifying a type, you help the Bicep compiler catch type-related errors during compilation and make the code more maintainable.
82
+
Bicep supports **typed variables**, where you explicitly declare the data type of a variable to ensure type safety and improve code clarity. The Benefits of typed variables:
83
83
84
-
#### Syntax for typed variables
84
+
-**Error detection**: The Bicep compiler validates that assigned values match the declared type, catching errors early.
85
+
-**Code clarity**: Explicit types make it clear what kind of data a variable holds.
86
+
-**Intellisense support**: Tools like Visual Studio Code provide better autocompletion and validation for typed variables.
87
+
-**Refactoring safety**: Ensures that changes to variable assignments don’t inadvertently break type expectations.
88
+
89
+
To define a typed variable, use the `var` keyword followed by the variable name, a colon (`:`), the type, and the assigned value:
85
90
86
-
To define a typed variable, use the `var` keyword followed by the variable name, a colon (`:`), the type, and the assigned value.
91
+
```bicep
92
+
@<decorator>(<argument>)
93
+
var <variable-name>: <data-type> = <variable-value>
94
+
```
95
+
96
+
The following examples show how to define typed variables:
0 commit comments