Dear all,
ListBuffer
does have the familiar dropRight
method. It also has the in-place --=
expected of a Buffer
– albeit only taking a TraversableOnce[A]
. Is there any hope it can also have an in-place dropRight
? A syntax like myListBuffer --= n
feels convenient to me (where n
is the number of elements to drop from the end of myListBuffer
).
I do already know that there is the possibility of getting the same end-result using
myListBuffer --= myListBuffer.drop(myListBuffer.size - n)
But, that’s an overkill because the temporary collection produced by myListBuffer.drop(myListBuffer.size - n)
is more than what is required for doing simply an in-place dropRight
. Merely n
suffices.
Cheers,
–Hossein