I need a (mutable) Seq
that is only Growable
. I do not need to update any index or shrink the collection or transform
it (or any other form of mutation), Just grow it (+=
) and I want to actively protect the collection from other mutations.
- The problem with
Buffer
s is that they are not justGrowable
but alsoShrinkable
and can betransformed
. - (mutable.)
Seq
is notShrinkable
but it can transform and it is notGrowable
To my (cursory) understanding of scala collection, there is no concrete implementation that has the exact traits that I'm looking for so I believe I have to implement my own?
EDIT:
I tried
val hands : collection.Seq[Team] with Growable[Team] = mutable.Seq[Team]()
in an attempt to make the nominal type conform to my requirements, actively preventing the client to call the undesired mutating methods on hands
but it says types does not conform.