VectorBuilder not intended for direct use. If you want to get a builder for Vector , you only need to call Vector.newBuilder[T] , which returns Builder[T, Vector[T]] (with the base instance, VectorBuilder ).
So, if you want the default builder to be used to create Seq , you only need to call Seq.newBuilder :
scala> Seq(1,2,3) res0: Seq[Int] = List(1, 2, 3) scala> Seq.newBuilder[Int] res1: scala.collection.mutable.Builder[Int,Seq[Int]] = ListBuffer() scala> Seq.newBuilder[Int].result res2: Seq[Int] = List()
The above shows that the default implementation of Seq is a list, and, logically, the default builder for Seq is actually mutable.ListBuffer .
ListBuffer more than just a List constructor, so it is in collection.mutable , while VectorBuilder not a Buffer , it cannot be used for anything other than building a Vector . This is probably why it is locally defined in Vector . I'm not sure why this is not private , I do not see links in it in the public Vector API. Maybe it should be (personal).
Just for reference, hidden magic doesn't happen with CanBuildFrom , it almost always goes through newBuilder above:
If you do not specify the expected type of collection, as in Seq(1,2).map(_+1) , only the available CanBuildFrom appears from the companion object a Seq and has the type CanBuildFrom[Seq[_], T, Seq[T]] . This means that the result will also be Seq .
Like most companion collection objects, the CanBuildFrom Seq instance provides only one thing: calling Seq.newBuilder (which is defined in GenTraversableFactory ...)
This is why CanBuildFrom for Vector uses VectorBuilder . For example, in this:
scala> Vector(1,2,3).map(_+1) res12: scala.collection.immutable.Vector[Int] = Vector(2, 3, 4)
Used builder:
scala> implicitly[CanBuildFrom[Vector[Int], Int, Vector[Int]]].apply() res13: scala.collection.mutable.Builder[Int,Vector[Int]] = scala.collection.immutable.VectorBuilder@43efdf93