terraform/website/docs/language/functions/coalescelist.mdx

43 lines
780 B
Plaintext
Raw Normal View History

---
2021-12-15 03:41:17 +01:00
page_title: coalescelist - Functions - Configuration Language
description: |-
The coalescelist function takes any number of list arguments and returns the
first one that isn't empty.
---
# `coalescelist` Function
`coalescelist` takes any number of list arguments and returns the first one
that isn't empty.
## Examples
```
> coalescelist(["a", "b"], ["c", "d"])
[
"a",
"b",
]
> coalescelist([], ["c", "d"])
[
"c",
"d",
]
```
To perform the `coalescelist` operation with a list of lists, use the `...`
symbol to expand the outer list as arguments:
```
> coalescelist([[], ["c", "d"]]...)
[
"c",
"d",
]
```
## Related Functions
2021-12-15 03:41:17 +01:00
* [`coalesce`](/language/functions/coalesce) performs a similar operation with string
arguments rather than list arguments.