StructNew

Creates an empty structure.

The shorthand syntax for a structNew is {};.

You can also create structures with data using this syntax:

  • a normal structure { "key": value };
  • a linked/ordered structure use [ "key": value ];
StructNew( [ type ] )

Returns: Struct

Argument Description Default
type
string, optional

the type of structure created:

  • linked: a struct with linked or ordered keys that maintain their insertion order
  • normal (default): a regular struct
  • soft: a struct with soft reference values, which are cleared at the discretion of the garbage collector in response to memory demand.
  • weak: a struct containing weakly referenced values, which do not prevent their referents from being garbage collected. Weak references are most often used to implement simple caches.

Note, the type "synchronized" is no longer supported and will be ignored; all struct/scopes are "thread safe" since version 4.1.

normal

Examples

Lucee Script

st = structNew("soft");
st = structNew("weak");
st = structNew("linked");
st = {
    "one": [1,2,3],
    "two": {
        "three": QueryNew("id")
    }
};
dump( st );
dump( structKeyList(st) );
dump( structKeyExists(st, "one") );

Lucee Tags

<cfset st = structNew()> 

See also