mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-22 03:07:51 -05:00
Signed-off-by: Janos <86970079+janosdebugs@users.noreply.github.com> Signed-off-by: Damian Stasik <920747+damianstasik@users.noreply.github.com> Signed-off-by: Roman Grinovski <roman.grinovski@gmail.com> Co-authored-by: Damian Stasik <920747+damianstasik@users.noreply.github.com> Co-authored-by: Roman Grinovski <roman.grinovski@gmail.com>
43 lines
755 B
Plaintext
43 lines
755 B
Plaintext
---
|
|
sidebar_label: coalescelist
|
|
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
|
|
|
|
* [`coalesce`](../../language/functions/coalesce.mdx) performs a similar operation with string
|
|
arguments rather than list arguments.
|