Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I have a Scala List, how can I get a TraversableOnce?

Tags:

scala

Starting with a Scala list.

val list = List(1,2,3,4)

How can I convert it to a TraversableOnce?

like image 485
Phil Avatar asked Dec 07 '13 12:12

Phil


1 Answers

You already have one, since List[A] is a subtype of TraversableOnce[A]. You should not need to do anything to convert it.

To verify this:

scala> implicitly[List[Int] <:< TraversableOnce[Int]]
res0: <:<[List[Int],TraversableOnce[Int]] = <function1>
like image 145
Ben James Avatar answered Sep 28 '22 18:09

Ben James