Skip to main content

Length

len

  • len(variable)
    • if variable is primitive string, returns the length of the input string
    • if variable is primitive list, returns the length of the list
    • if variable is primitive map, returns the number of key-value pairs in the map
    • if variable is json array, returns the number of elements in the array
    • if variable is json object, returns the number of key-value pairs in the object
    • if variable is Tuple, returns the number of elements in the tuple
    • if variable is Map, returns the number of key-value pairs in the map
    • if variable is Table, returns row count of the table
    • if variable is MetricStream, returns the number of data series in the metric
    • if variable is Alert, returns the number of entries in the alert
    • else return 0
len("Hello") // return an int64 value of 5
len([1, 2, 3]) // return an int64 value of 3
len({Name: "foo", Domain: "@gmail.com"}) // return an int64 value of 2