github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/website/content/docs/job-specification/hcl2/functions/collection/coalesce.mdx (about)

     1  ---
     2  layout: docs
     3  page_title: coalesce - Functions - Configuration Language
     4  sidebar_title: coalesce
     5  description: |-
     6    The coalesce function takes any number of arguments and returns the
     7    first one that isn't null nor empty.
     8  ---
     9  
    10  # `coalesce` Function
    11  
    12  `coalesce` takes any number of arguments and returns the first one
    13  that isn't null or an empty string.
    14  
    15  ## Examples
    16  
    17  ```shell-session
    18  > coalesce("a", "b")
    19  a
    20  > coalesce("", "b")
    21  b
    22  > coalesce(1,2)
    23  1
    24  ```
    25  
    26  To perform the `coalesce` operation with a list of strings, use the `...`
    27  symbol to expand the list as arguments:
    28  
    29  ```shell-session
    30  > coalesce(["", "b"]...)
    31  b
    32  ```
    33  
    34  ## Related Functions
    35  
    36  - [`coalescelist`](/docs/job-specification/hcl2/functions/collection/coalescelist) performs a similar operation with
    37    list arguments rather than individual arguments.