I have a strong (possibly misguided) expectation in Scala collections that += adds an element to a collection in the “default way”. Therefore, I was shocked to discover that in the new ArrayDeque implementation of mutable.Stack, the push method and the += method add to opposite ends of the stack, with push adding to the “top” and += adding to the “bottom”.
I understand exactly how this happened (+= was inherited from ArrayDeque) but it feels incredibly broken. And it has tripped up more than one of my students.
Although it would be trivial to fix, I also realize that any such fix risks breaking existing code. At the minimum, I would hope for a prominent warning in the API.
(This problem didn’t arise in the old version of Stack because it didn’t support +=.)