This version is out of date, covering development from v5.0.0 to v5.12.2. It is maintained here only for inbound reference links from elsewhere.

Jump to the current version of aTbRef.

Tinderbox Icon

List/Set.intersect(set)


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Operator First Added: 

Operator Altered: 

 Function   [other Function type actions]

 List   [operators of similar scope]

 Data manipulation   [other Data manipulation operators]

 5.10.2

 


Set.intersect(set)

This calculates the intersection of two List or Sets. Intersect is generally intended for Set but will work with Lists, though the result is always a Set.

$MySet = $MySetA.intersect($MySetB) 

$MySet = $MyList1.intersect($MyList2) 

The result is a Set of all items in both $MySetA and $MySetB, or in the second example in both $MyList1 and $MyList2. As the result is always a set, any source list items are de-duped in the output.

Non-intersect

No special code is needed to find items in one set but not the other:

$MySetC = $MySetA - $MySetB gives items only in $MySetA

$MySetC = $MySetB - $MySetA gives items only in $MySetB

Use with Lists

Subtracting a Set from a List results in only one instance of each Set item being removed. Subtracting a List from a List each instance of a value in the second list is removed so multiple source List entries may be removed.


Possible relevant notes (via "Similar Notes" feature):


A Tinderbox Reference File : Actions & Rules : Operators : Full Operator List : List/Set.intersect(set)