structKeyArray

Returns the keys in a CFML structure as an array. If structure does not exist throws an exception.

structKeyArray(structure) → returns Array

Member Function Syntax

someStruct.keyArray()

Argument Reference for the structKeyArray function

structure

Required: Yes

Examples sample code invoking the structKeyArray function


Traditional function

statusCodes = {
    OK = 200,
    CREATED = 201,
    NOT_MODIFIED = 304,
    BAD_REQUEST = 400,
    NOT_FOUND = 404
};

writeDump(structKeyArray(statusCodes));

Expected Result: [NOT_FOUND, BAD_REQUEST, CREATED, OK, NOT_MODIFIED]


Using Member Function

CF 11+ Lucee 4.5+ Retrieve a comma seperated list of keys using the member function

statusCodes = {
    OK = 200,
    CREATED = 201,
    NOT_MODIFIED = 304,
    BAD_REQUEST = 400,
    NOT_FOUND = 404
};

writeDump(statusCodes.keyArray());

Expected Result: [NOT_FOUND, BAD_REQUEST, CREATED, OK, NOT_MODIFIED]


Fork me on GitHub