forall
trait Collection[A] {
def forall(p: (A) => Boolean): Boolean
}
forall
checks whether all elements in this collection satisfy the predicate p
, returning false
if p
doesn’t stand for at least one element.
On empty collections there is no element which doesn’t satisfy p
, hence this function returns true
.