length
Counts the characters in text, the items in a list or the keys in a record.
Details #
length(value) takes exactly one argument and returns a number.
Text: the number of characters.
length("héllo")is 5.List: the number of items.
Record: the number of keys.
Nothing (
null): 0.Anything else is turned into text first, so
length(1234)is 4.
value.length gives the same count for text and lists.
Parameters #
Takes 1 argument.
{{ length(text) }}
Examples #
length("héllo")→
5length(items)→
3| Sample variable | Value |
|---|---|
items | ["a", "b", "c"] |
items.length > 2 ? "many" : "few"→
many| Sample variable | Value |
|---|---|
items | ["a", "b", "c"] |
Gotchas #
.lengthon a record is not the key count; it reads a field calledlength. Uselength(record).