Main Content

numEntries

Number of key-value pairs in dictionary

Since R2022b

    Description

    n = numEntries(d) returns the number of key-value pairs stored in the specified dictionary. If d is an unconfigured dictionary, then numEntries returns 0.

    example

    Examples

    collapse all

    Create a dictionary containing several key-value pairs.

    names = ["Unicycle" "Bicycle" "Tricycle"];
    wheels = [1 2 3];
    d = dictionary(wheels,names)
    d =
    
      dictionary (double --> string) with 3 entries:
    
        1 --> "Unicycle"
        2 --> "Bicycle"
        3 --> "Tricycle"
    

    Use numEntries to determine how many key-value pairs are stored in d.

    n = numEntries(d)
    n = 
    3
    

    Input Arguments

    collapse all

    Dictionary, specified as a dictionary object.

    Extended Capabilities

    Version History

    Introduced in R2022b

    expand all