Contains() with predicate?

I don’t think it will improve consistency.

any(p: (T) -> Boolean): Boolean is paired with all(p: (T) -> Boolean): Boolean.
They work like the mathematical quantifiers “there exists (∃)” and “for all (∀)”, respectively.

They are the same as exists(predicate) and forall(predicate) in Scala.

You now, all(element: T) does not make much sense, because it will be true only if all of the elements of the collection is the same.

1 Like