To count the number of elements in a collection that match a given predicate / condition, we can use the count() function :
count()
// Syntax : coll.count { /* Predicate */ }
Example :