Struct.exists Method

Determines whether a particular item exists in a struct.

Syntax

public boolean exists(str fieldName)

Run On

Called

Parameters

  • fieldName
    Type: str
    The name of the item to check for.

Return Value

Type: boolean
true if the item exists in the struct; otherwise, false.

Examples

The following example tests whether a particular item exists in a struct, and if not, it adds the item and assigns a value to it using the Struct.add method.

client server static void setProp( 
    Struct     properties, 
    str        name, 
    anytype   value 
    ) 
{ 
    if (! properties.exists(name)) 
    { 
        properties.add(name,nullValue(value)); 
    } 
    properties.value(name,value); 
}

See Also

Struct Class

Struct.add Method

Struct.fields Method