I have looked at this question but still don't understand the difference between Iterable and Traversable traits. Can someone explain ?
Think of it as the difference between blowing and sucking.
When you have call a Traversable
s 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.