Scala: What is the difference between Traversable and Iterable traits in Scala collections?

Think of it as the difference between blowing and sucking.

When you have call a Traversables foreach, or its derived methods, it will blow its values into your function one at a time – so it has control over the iteration.

With the Iterator returned by an Iterable though, you suck the values out of it, controlling when to move to the next one yourself.

Leave a Comment