🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators intersection
This page was created by Alexandra on 2017-08-13. Last edited by 62.169.16.147 on 2026-09-12.

intersection ( bag : Bag(T) ) : Bag(T)[edit source]

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}

See: Examples_on_collection_operators