Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Calculates and returns the identical values found in two sets.
Syntax
client server public static Set intersection(Set set1, Set set2)
Run On
Called
Parameters
- set1
Type: Set Class
The first set to be compared.
- set2
Type: Set Class
The second set to be compared.
Return Value
Type: Set Class
A set containing the elements found in both sets.
Examples
The following example creates two sets of integers and adds some values to them. It then prints a list of the values that are that is contained in both 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::intersection(is, is1);
// Prints "{2}" because 2 is contained in both is and is2.
print is2.toString();
}