This version is out of date, covering development from v9.5.0 to v9.7.3. It is maintained here only for inbound reference links from elsewhere. It is no longer actively updated.

Jump to the current version of aTbRef

Tinderbox v9 Icon

List/Set.intersect(aSet)


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Operator First Added: 

Operator Last Altered: 

 Function  [other Function type actions]

 List  [operators of similar scope]

 Data manipulation  [other Data manipulation operators]

 Baseline

 As at baseline


Set.intersect(aSet)

This calculates the intersection of two List or Sets, the chained Set and the set in the aSet argument The .intersect() test is generally intended for use with Set-type data 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.