Set::union Method [AX 2012]

Calculates and retrieves the union of two given sets. This is the set that contains the values found in at least one of the sets.

client server public static Set union(Set set1, Set set2)

Run On

Called

Parameters

set1
Type: Set Class
The first of the two sets that are compared.
set2
Type: Set Class
The second of the two sets that are compared.

Return Value

Type: Set Class
The set containing elements found in set1 or set2.

The two sets that are compared must be of the same type.

The following example creates two sets of integers and adds some values to them. It then creates a new set that contains all the values that are contained in either of the sets.

{ 
    Set is = new Set (Types::Integer); 
    Set is2, is1 = new Set (Types::Integer); 
    ; 
  
    is.add(1); 
    is.add(2); 
    is.add(3); 
    is1.add(2); 
    is1.add(4); 
    is2 = Set::union(is, is1); 
  
    // Prints "{1, 2, 3, 4}". 
    print is2.toString(); 
    pause; 
}
Show: