try()

The function that returns the first of its arguments that evaluates without an error, used to supply a fallback.

In more detail

try(local.names[0], "nobody") returns the first name, or "nobody" if the list is empty. Use it for deliberate fallbacks, not to hide real mistakes.

Example

first = try(local.normalised[0], "nobody")

Related terms

Taught in

References