Skip to main content
length(collection) returns the number of elements in a list, tuple, set, or map.

Signature

Example

Guard a deployment task so it only runs when at least one target service is specified:
When --var 'services=[]' is passed or the default is used, the task is skipped. When services are provided, the deployment proceeds.

Notes

  • length works on lists, sets, maps, and tuples. It does not work on strings, numbers, or booleans.
  • For maps, length returns the number of keys.