Skip to main content
compact(list) returns a new list with all empty string and null elements removed.

Signature

Example

Build a list of Docker build arguments, where some are optional. Empty entries are filtered out before the list is joined into a command:
When neither proxy variable is set, computed.build_args is empty and the command becomes docker build ..

Notes

  • compact only operates on list(string). It does not apply to lists of other types.
  • Use compact after producing a list where some elements may be conditionally empty.