Skip to content

Commit 0b22715

Browse files
committed
clarify order of union
1 parent 27c1e94 commit 0b22715

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

articles/azure-resource-manager/bicep/bicep-functions-array.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ The output from the preceding example with the default values is:
746746

747747
`union(arg1, arg2, arg3, ...)`
748748

749-
Returns a single array or object with all elements from the parameters. Duplicate values or keys are only included once.
749+
Returns a single array or object with all elements from the parameters. For arrays, duplicate values are included once. For objects, duplicate property names are only included once.
750750

751751
Namespace: [sys](bicep-functions.md#namespaces-for-functions).
752752

@@ -762,6 +762,14 @@ Namespace: [sys](bicep-functions.md#namespaces-for-functions).
762762

763763
An array or object.
764764

765+
### Remarks
766+
767+
The union function uses the sequence of the parameters to determine the order and values of the result.
768+
769+
For arrays, the function iterates through each element in the first parameter and adds it to the result if it isn't already present. Then, it repeats the process for the second parameter and any additional parameters. If a value is already present, it's earlier placement in the array is preserved.
770+
771+
For objects, property names and values from the first parameter are added to the result. For later parameters, any new names are added to the result. If a later parameter has a property with the same name, that value overwrites the existing value. The order of the properties isn't guaranteed.
772+
765773
### Example
766774

767775
The following example shows how to use union with arrays and objects:
@@ -788,6 +796,7 @@ param firstArray array = [
788796
param secondArray array = [
789797
'three'
790798
'four'
799+
'two'
791800
]
792801
793802
output objectOutput object = union(firstObject, secondObject)

articles/azure-resource-manager/bicep/bicep-functions-object.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ The output from the preceding example with the default values is:
276276

277277
`union(arg1, arg2, arg3, ...)`
278278

279-
Returns a single array or object with all elements from the parameters. Duplicate values or keys are only included once.
279+
Returns a single array or object with all elements from the parameters. For arrays, duplicate values are included once. For objects, duplicate property names are only included once.
280280

281281
Namespace: [sys](bicep-functions.md#namespaces-for-functions).
282282

@@ -292,6 +292,14 @@ Namespace: [sys](bicep-functions.md#namespaces-for-functions).
292292

293293
An array or object.
294294

295+
### Remarks
296+
297+
The union function uses the sequence of the parameters to determine the order and values of the result.
298+
299+
For arrays, the function iterates through each element in the first parameter and adds it to the result if it isn't already present. Then, it repeats the process for the second parameter and any additional parameters. If a value is already present, it's earlier placement in the array is preserved.
300+
301+
For objects, property names and values from the first parameter are added to the result. For later parameters, any new names are added to the result. If a later parameter has a property with the same name, that value overwrites the existing value. The order of the properties isn't guaranteed.
302+
295303
### Example
296304

297305
The following example shows how to use union with arrays and objects:
@@ -318,6 +326,7 @@ param firstArray array = [
318326
param secondArray array = [
319327
'three'
320328
'four'
329+
'two'
321330
]
322331
323332
output objectOutput object = union(firstObject, secondObject)

articles/azure-resource-manager/templates/template-functions-array.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ The output from the preceding example with the default values is:
475475

476476
`union(arg1, arg2, arg3, ...)`
477477

478-
Returns a single array or object with all elements from the parameters. Duplicate values or keys are only included once.
478+
Returns a single array or object with all elements from the parameters. For arrays, duplicate values are included once. For objects, duplicate property names are only included once.
479479

480480
### Parameters
481481

@@ -489,6 +489,14 @@ Returns a single array or object with all elements from the parameters. Duplicat
489489

490490
An array or object.
491491

492+
### Remarks
493+
494+
The union function uses the sequence of the parameters to determine the order and values of the result.
495+
496+
For arrays, the function iterates through each element in the first parameter and adds it to the result if it isn't already present. Then, it repeats the process for the second parameter and any additional parameters. If a value is already present, it's earlier placement in the array is preserved.
497+
498+
For objects, property names and values from the first parameter are added to the result. For later parameters, any new names are added to the result. If a later parameter has a property with the same name, that value overwrites the existing value. The order of the properties isn't guaranteed.
499+
492500
### Example
493501

494502
The following example shows how to use union with arrays and objects.

articles/azure-resource-manager/templates/template-functions-object.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ The output from the preceding example is:
258258

259259
`union(arg1, arg2, arg3, ...)`
260260

261-
Returns a single array or object with all elements from the parameters. Duplicate values or keys are only included once.
261+
Returns a single array or object with all elements from the parameters. For arrays, duplicate values are included once. For objects, duplicate property names are only included once.
262262

263263
### Parameters
264264

@@ -272,6 +272,14 @@ Returns a single array or object with all elements from the parameters. Duplicat
272272

273273
An array or object.
274274

275+
### Remarks
276+
277+
The union function uses the sequence of the parameters to determine the order and values of the result.
278+
279+
For arrays, the function iterates through each element in the first parameter and adds it to the result if it isn't already present. Then, it repeats the process for the second parameter and any additional parameters. If a value is already present, it's earlier placement in the array is preserved.
280+
281+
For objects, property names and values from the first parameter are added to the result. For later parameters, any new names are added to the result. If a later parameter has a property with the same name, that value overwrites the existing value. The order of the properties isn't guaranteed.
282+
275283
### Example
276284

277285
The following example shows how to use union with arrays and objects:

0 commit comments

Comments
 (0)