-
Notifications
You must be signed in to change notification settings - Fork 1
Length
ricardoboss edited this page Oct 16, 2023
·
2 revisions
The length
function takes a string, list, or map, and returns the count of
characters or items.
length(string text)
length(list myList)
length(map myMap)
-
text
is the string whose length to calculate. -
myList
ormyMap
are collections whose items to count.
- For
text
, each whitespace counts as one character. So, two spaces are two characters, a line break is one character, and so on. - For
text
, the length is the number of so called grapheme clusters, not the number of bytes. So, a single character can be multiple bytes. For example, '🤷♂️' is treated as one character, not 5.
length("Hello!") // 6
length([1, 2, 3, 4]) // 4
length({ "a": 1, "b": 2, "c": 3 }) // 3
length("🤷♂️") // 1
© 2023 Ricardo Boss • Licensed under MIT • Want to update this page? Edit it on GitHub and submit a pull request!