The next trait from the top in the collections hierarchy is Iterable
. All methods in this trait are defined in terms of an abstract method, iterator
, which yields the collection’s elements one by one. The foreach
method from trait Traversable
is implemented in Iterable
in terms of iterator
. Here is the actual implementation:
This is a companion discussion topic for the original entry at http://docs.scala-lang.org//overviews/collections/trait-iterable.html