Struct.remove Method

Removes an item from a struct.

Syntax

public boolean remove(str fieldName)

Run On

Called

Parameters

  • fieldName
    Type: str
    The name of the item you want to remove.

Return Value

Type: boolean
true if the item was found (and removed); otherwise, false.

Remarks

The name you specify for the fieldName parameter must be the name of the item as it was specified in the instantiation of the struct or the name of the item as it was added using the Struct.add method. The name must be enclosed in quotes (" ").

Examples

The following example creates a struct with two items in it and prints a description of these items. One of the items is then removed by using the remove method.

{ 
    Struct s = new Struct ("str name; int age"); 
 
    // Values are assigned to the two items 
    s.value("name", "John"); 
    s.value("age", 34); 
  
    // Prints a description of the items in the struct 
    print s.definitionString(); 
    pause; 
 
    // Removes the name field 
    s.remove("name"); 
 
    // Describes remaining items in the struct 
    print s.definitionString(); 
    pause; 
}

See Also

Struct Class

Struct.add Method