I’m learning about collections, and I just noticed these two methods in the Traversable docs. What’s the point of the first one? The second one seems to include it.
copyToArray (xs: Array[A], start: Int, len: Int): Unit
copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Unit
You are correct that the second subsumes the first. However, the first doesn’t actually exist. If you look closer at the docs you’ll see the words
[use case]:A
[use case]in the Scala API shows a simplified form of the signature. This gives the “typical” use in a way that isn’t so scary to new Scala programmers who might otherwise be confused by the crazy type signatures.You see the same thing with many other methods, including
map(in which theCanBuildFromstuff is hidden):To read an old post where Martin Odersky discusses the issue, see here.