OCLOperators intersection
No edit summary
No edit summary
 
(12 intermediate revisions by 5 users not shown)
Line 1: Line 1:
The intersection of two collections
<message>Write the content here to display this box</message>
=== intersection ( bag : Bag(T) ) : Bag(T) ===
Returns a Bag containing all elements of ''self'' that are also contained by *bag*.
{| class="wikitable"
!Expression
!Result
|-
|Bag{'a', 'b', 'a'}->intersection(Bag{'a', 'b'})
|Bag{'a', 'b'}
|-
|Bag{'a', 'b', 'a', 'b'}->intersection(Bag{'a', 'b', 'b'})
|Bag{'b', 'a', 'b'}
|-
|Set{1,2,3}->intersection(Set{2,3,4})
|Set{2,3}
|}
[[File:2019-11-25 13h29 19.png|none|thumb]]'''See:''' [[Documentation:Examples on collection operators|Examples_on_collection_operators]]


Example for A,B,C,D and C,D,E intersection is C,D
{{Edited|July|12|2025}}
[[Category:OCLOperators]]
[[Category:OCL Collection Operators]]

Latest revision as of 05:56, 23 January 2025

This page was created by Alexandra on 2017-08-13. Last edited by Stephanie@mdriven.net on 2025-01-23.

intersection ( bag : Bag(T) ) : Bag(T)

Returns a Bag containing all elements of self that are also contained by *bag*.

Expression Result
Bag{'a', 'b', 'a'}->intersection(Bag{'a', 'b'}) Bag{'a', 'b'}
Bag{'a', 'b', 'a', 'b'}->intersection(Bag{'a', 'b', 'b'}) Bag{'b', 'a', 'b'}
Set{1,2,3}->intersection(Set{2,3,4}) Set{2,3}
2019-11-25 13h29 19.png

See: Examples_on_collection_operators