How to append or prepend on a Scala mutable.Seq

后端 未结 1 386
鱼传尺愫
鱼传尺愫 2021-02-02 06:00

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

相关标签:
1条回答
  • 2021-02-02 06:25

    Mutability for sequences only guarantees that you'll be able to swap out the items for different ones (via the update method), as you can with e.g. primitive arrays. It does not guarantee that you'll be able to make the sequence larger (that's what the Growable trait is for) or smaller (Shrinkable).

    Buffer is the abstract trait that contains Growable and Shrinkable, not Seq.

    0 讨论(0)
提交回复
热议问题