You can use minValue in OCL when you need the lowest value in a collection of simple values, such as the smallest number in a collection of amounts.
Syntax
collection->minValue()
collection is the collection to evaluate. minValue() returns the lowest value in that collection.
Example
If a collection contains the values 12, 4, and 9, this expression returns 4:
values->minValue()
Use minValue() when the values to compare are already in a collection. For example, if an expression produces a collection of order amounts, applying ->minValue() returns the lowest amount in that result.
Here are additional examples showing minValue() results:
| Expression | Result |
|---|---|
| (Bag{3, 2, 1, 6})->minValue | 1 |
Choose the correct minimum operator
| Need | Operator | Example result |
|---|---|---|
| Find the lowest value in a collection | collection->minValue()
|
The lowest value among all items in collection
|
| Compare one number with another number | Number::min | The lower of the two numbers |
Related operators
Use maxValue when you need the highest value in a collection. Before evaluating a collection whose contents are optional, use isEmpty to test whether it contains any items.
