Reputation: 4417
I'm looking at this snippet:
val here: Array[Int] = rdd.collect()
println(here.toList)
... looking at the source for toList
(on TraversableOnce
) and Array
(Array
does not inherit TraversableOnce
though), but I can't find the connection that will make Scala consider an Array
as a TraversableOnce
- if that is even what happens. Is there some implicit at work here? Is there a conversion via ArraySeq
or WrappedArray
? How does that toList
work?
Upvotes: 2
Views: 760
Reputation: 3725
Array does not extend TraversableOnce
, but it is implicitly convertible to IndexedSeq
, which does!
This means that internally, the array is converted to a WrappedArray
, then toList
is called on this.
See here for more info: http://www.scala-lang.org/docu/files/collections-api/collections_38.html
Upvotes: 4