Scala - What is the difference between size and length of a Seq?

YoBre picture YoBre · Apr 9, 2014 · Viewed 47.3k times · Source

What is the difference between size and length of a Seq? When to use one and when the other?

scala> var a :Seq[String] = Seq("one", "two")
a: Seq[String] = List(one, two)

scala> a.size
res6: Int = 2

scala> a.length
res7: Int = 2

It's the same?

Thanks

Answer

Peter picture Peter · Apr 9, 2014

Nothing. In the Seq doc, at the size method it is clearly stated: "The size of this sequence, equivalent to length.".