In-Place dropRight for ListBuffer

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

you might look at https://github.com/scala/collection-strawman and try to find out what the current situation is w/r/t in-place operations on mutable collections. (the collections API isn’t changing anymore for 2.12, and the collection-strawman is where work on the 2.13 collections is happening)

Thank you Seth. I created an issue (#485, to be more precise) in collection-strawman.