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

reject ( expr : OclExpression ) : Collection(T)[edit source]

Returns a collection with all elements of self except for those that validate the OclExpression expr.

Expression Result
Sequence{1, 2, 3}->reject(i : Integer | i > 1 ) Sequence{1}
Bag{1, 2, 3}->reject(i : Integer | i > 1 ) Bag{1}
OrderedSet{1, 2, 3}->reject(i : Integer | i > 1 ) OrderedSet{1}
Set{1, 2, 3}->reject(i : Integer | i > 1 ) Set{1}


Example[edit source]

Bag{1, 2, 3}->reject(i | i < 2 )

This returns 2 and 3 because anything less than 2 is rejected.