You can use maxValue in OCL when you need the highest value in a collection of simple value objects.
What maxValue returns
maxValue returns the highest (maximum) value from a collection of simple value objects.
For example, if a collection contains the values 12, 24, and 18, maxValue returns 24.
Here are some examples of maxValue in use:
| Expression | Result |
|---|---|
| (Bag{3, 2, 1, 6})->maxValue | 6 |
| Bag{DateTime.Parse('2019-01-01'), DateTime.Parse('2018-12-01')}->maxValue | '2019-01-01' |
When to use it
Use maxValue when your expression already produces a collection and you need its largest value.
For example, a collection of measured values can use maxValue to identify the greatest measurement rather than processing every value individually.
Related operators
maxValue finds the greatest value in a collection. To find the lowest value in a collection, use minValue.
To compare two numbers, use Number::max ( r : Number ) : Number instead.
