OCLOperators excluding
No edit summary
No edit summary
 
(10 intermediate revisions by 5 users not shown)
Line 1: Line 1:
<message>Write the content here to display this box</message>
=== excluding ( object : T ) : Collection(T) ===
=== excluding ( object : T ) : Collection(T) ===
Returns a collection containing all elements of ''self'' minus all occurences of ''object''. **Note** : at the time of writing, the OCL standard library sports a bug which changes *OrderedSets* in *Sets* when excluding elements.
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"
{| class="wikitable"
!Expression
!Expression
Line 17: Line 20:
|Set{'c', 'a'}
|Set{'c', 'a'}
|}
|}
[[Category:OCLOperators]]
The opposite - to add an object to a collection - is [[Documentation:OCLOperators append|Append]].
 
'''Video:''' [https://youtu.be/nKJ4HInnaDE?si=fod79HGQZO4sf35y OCL Operators: excluding]
[[Category:OCL Collection Operators]]
{{Edited|July|12|2025}}

Latest revision as of 05:29, 10 February 2025

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

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.

Video: OCL Operators: excluding