There's something I don't understand about Scala's collection.mutable.Seq
. It describes the interface for all mutable sequences, yet I don't see methods to append or prepend elements without creating a new sequence. Am I missing something obvious here?
There are :+
and +:
for append and prepend, respectively, but they create new collections — in order to be consistent with the behavior of immutable sequences, I assume. This is fine, but why is there no method like +=
and +=:
, like ArrayBuffer
and ListBuffer
define, for in-place append and prepend? Does it mean that I cannot refer to a mutable seq that's typed as collection.mutable.Seq
if I want to do in-place append?
Again, I must have missed something obvious, but cannot find what…