OCLOperators count
This page was created by Alexandra on 2017-08-13. Last edited by Wikiadmin on 2026-09-12.
Syntax
collection->count(value)
count ( object : T ) : Integer[edit source]
Returns how many times object is in the collection self.
| Expression | Result |
|---|---|
| Sequence{2.3, 5.2}->count(5.2) | 1 |
| Set{3, 'test', 4.0, 4, 4.0, 'test'}->count(null) | 0 |
| Set{3, null, 4.0, null, 'test'}->count(null) | 1 |
| Bag{3, null, 4.0, null, 'test'}->count(null) | 2 |
Count how many customers are named ‘John’
Customer.allInstances.Name->count('John')
