The difference and conversion between Seq[Int] and List[Int]

前端 未结 1 1601
独厮守ぢ
独厮守ぢ 2021-01-18 15:19

When I input Seq(1,2,3) in REPL, it returns me List(1,2,3)

scala> Seq(1,2,3)
res8: Seq[Int] = List(1, 2, 3)

Th

相关标签:
1条回答
  • 2021-01-18 15:50

    Seq is a base trait (interface) for sequences and List is a concrete implementation of that interface.

    Every instance of List is already a Seq so there's no need to convert anything. You can use toSeq method, but I don't see any reason to do so. To convert Seq to a List use toList method.

    0 讨论(0)
提交回复
热议问题