exists
trait Collection[A] {
def exists(p: (A) => Boolean): Boolean
}
exists
checks whether at least one element in this collection satisfy the predicate p
, returning true
if such element exists.
On empty collections the predicate p
cannot be satisfied at least once, hence this function returns false
.