Skip to content

Commit 5279287

Browse files
committed
Add more information for the spread operator
1 parent 72854d5 commit 5279287

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

articles/azure-resource-manager/bicep/data-types.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ output bar bool = length(numberArray) <= 3 || numberArray[3] == 4
8383

8484
### Array-related functions
8585

86-
See [Array functions](./bicep-functions-array.md).
86+
* See [Array functions](./bicep-functions-array.md).
87+
* See [Lambda functions](./bicep-functions-lambda.md).
8788

8889
## Booleans
8990

articles/azure-resource-manager/bicep/operator-spread.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Bicep spread operator
33
description: Describes Bicep spread operator.
44
ms.topic: conceptual
55
ms.custom: devx-track-bicep
6-
ms.date: 08/07/2024
6+
ms.date: 11/20/2024
77
---
88

99
# Bicep spread operator
@@ -74,6 +74,24 @@ In this usage, comma isn't used between the two lines. Output from the example:
7474
|------|------|-------|
7575
| `objCombined` | object | { color: 'white', shape: 'circle' } |
7676

77+
The following example shows how to conditionally add an array element:
78+
79+
```bicep
80+
@allowed(['white', 'black'])
81+
param color string = 'black'
82+
83+
var colorWhite = { color: 'white' }
84+
var colorBlack = { color: 'black' }
85+
86+
output objB object = ((color == 'white')? { shape: 'circle', ...colorWhite} : { shape: 'circle', ...colorBlack})
87+
```
88+
89+
Output from the example:
90+
91+
| Name | Type | Value |
92+
|------|------|-------|
93+
| `objB` | object | { shape: 'circle', color: 'black' } |
94+
7795
The spread operation can be used to avoid setting an optional property. In the following example, _accessTier_ is set only if the parameter _tier_ isn't an empty string.
7896

7997
```bicep

0 commit comments

Comments
 (0)