Struct::merge Method

Combines two structs to create a new struct.

Syntax

client server public static Struct merge(Struct struct1, Struct struct2)

Run On

Called

Parameters

  • struct2
    Type: Struct Class
    The struct that will be added to the end of the first struct to create a new struct.

Return Value

Type: Struct Class
The new struct.

Remarks

struct2 is added to the end of struct1. This means that the order of the items in the new struct will be: all the items in struct1, arranged in alphabetical order of the item names, followed by all the items in struct2, arranged in alphabetical order of the item names. If both structs contain an item with the same name, only the item from the first struct will be included.

Examples

The following example creates two structs called person and address, and then merges them into a new struct called allInfo.

{ 
    container packedStruct; 
    Struct person = new Struct ("str name; int age"); 
    Struct address = new Struct ("str street; str city; str country"); 
    Struct allInfo; 
  
    person.value ("name", "Jane Dow"); 
    person.value ("age", 34); 
    address.value ("street", "Downing street 10"); 
    address.value ("country", "Great Britain"); 
    address.value ("city", " London"); 
  
    allInfo = Struct::merge(person, address); 
  
    print allInfo.toString(); 
    pause; 
}

See Also

Reference

Struct Class