Why is "contains" implemented in Seq, but not in Iterable or Traversable?

The following does not work:

val t: Traversable[Int] = Seq(0, 1, 2) t contains 0 

Even changing Traversable to Iterable doesn't help. You need to use Seq or t exists (_ == 0) .

When checking for an implementation, contains is implemented in SeqLike as follows:

 def contains[A1 >: A](elem: A1): Boolean = exists (_ == elem) 

As exists already implemented for Traversable , why not contains ?

+5
source share

Source: https://habr.com/ru/post/1260336/


All Articles