structCount

Counts the keys in a structure.

structCount(structure) → returns Numeric

structCount Argument Reference

structure
Required

Structure to access

Examples sample code invoking the structCount function


Using structCount as a function

Pass a structure as an argument to the function.

user = {
    id = 1,
    firstname = "Han",
    lastname = "Solo",
    movie = "Star Wars"
};

writeDump( structCount( user ) );

Expected Result: 4


Using structCount as a Member Function

CF 11+ Lucee 4.5+ Having a reference of a structure as a variable, use the dot notation to get a key count on it using a member function.

user = {
    id = 1,
    firstname = "Han",
    lastname = "Solo",
    movie = "Star Wars"
};

writeDump( user.count() );

Expected Result: 4


Fork me on GitHub