How reusable is ListBuffer?

I’ve been using this pattern in the past:

class Acc[A]:
   private val elems     = List.newBuilder[A]
   def += (x: A): Unit   = elems += x
   def snapshot: List[A] = elems.result()

val acc = Acc[Int]()
acc += 1
acc += 2
assert(acc.snapshot == List(1, 2))
acc += 3
assert(acc.snapshot == List(1, 2, 3))

It used to be explicitly allowed (I believe the staircase book mentioned it), but at some point, the documentation changed. Now, ReusableBuilder states: “In general no method other than clear() may be called after result() . It is up to subclasses to implement and to document other allowed sequences of operations”, and ListBuffer is silent (actually, List.newBuilder does not even state that is uses ListBuffer).

So, is the pattern still valid, and if so, could the documentation be improved to reflect it?

Yes, the docs could be improved. Is that the t-shirt they distribute when you arrive at a Scala Spree?

The implementation of toList shows that it tracks aliasing (whether element copy is required on update) and memory effects. It’s not obvious from the file history whether there was a point at which these features were committed to; there are some commits of scaladoc.

I might expect doc at the overview but that says it’s for previous versions.