OCLOperators excluding
(Created page with "The collection except this single object")
 
(Automatically adding template at the end of the page.)
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
The collection except this single object
=== excluding ( object : T ) : Collection(T) ===
Returns a collection containing all elements of ''self'' minus all occurrences of ''object''. '''Note:''' at the time of writing, the OCL standard library sports a bug that changes *OrderedSets* in *Sets* when excluding elements.
{| class="wikitable"
!Expression
!Result
|-
|Sequence{'b', 'a', 'b', 'c'}->excluding('b')
|Sequence{'a', 'c'}
|-
|Bag{'b', 'a', 'b', 'c'}->excluding('b')
|Bag{'c', 'a'}
|-
|OrderedSet{'b', 'a', 'b', 'c'}->excluding('b')
|Set{'c', 'a'}
|-
|Set{'b', 'a', 'b', 'c'}->excluding('b')
|Set{'c', 'a'}
|}
The opposite - to add an object to a collection - is [[OCLOperators append|Append]].
[[Category:OCL Collection Operators]]
{{Edited|July|12|2024}}

Latest revision as of 15:41, 10 February 2024

excluding ( object : T ) : Collection(T)

Returns a collection containing all elements of self minus all occurrences of object. Note: at the time of writing, the OCL standard library sports a bug that changes *OrderedSets* in *Sets* when excluding elements.

Expression Result
Sequence{'b', 'a', 'b', 'c'}->excluding('b') Sequence{'a', 'c'}
Bag{'b', 'a', 'b', 'c'}->excluding('b') Bag{'c', 'a'}
OrderedSet{'b', 'a', 'b', 'c'}->excluding('b') Set{'c', 'a'}
Set{'b', 'a', 'b', 'c'}->excluding('b') Set{'c', 'a'}

The opposite - to add an object to a collection - is Append.

This page was edited 89 days ago on 02/10/2024. What links here