Question 1 -
In the Scala documentation, I found that Traversable is a trait with an abstract method foreach
:
http://www.scala-lang.org/docu/files/collections-api/collections.html
Then, why could I instantiate an object of type Traversable?
val t = Traversable(1,2,3)
t.foreach(println _) //where is Scala picking foreach a definition from?
Question 2 - how is Traversable different from other classes like List or Array? Does it come under Seq, Set or Map category ( I thought other collection inherit from Traversable)
Question 3 - I could do exactly the same for the Iterable
trait even though as per documentation, Iterable has an abstract method, iterator
:
val v1 = Iterator(1,2,3)
v1.foreach( println _)
What am I missing?