Yukihiro Matsumoto wrote: > > Hi, > > In message "[ruby-talk:17775] Re: What is Array#- ?" > on 01/07/13, Stephan KçÎper <Stephan.Kaemper / Schleswig-Holstein.de> writes: > > |The point here is that Array#- works as if the Array were a set - and > |consquently treats it appropriately by removing duplicates. > > Both behaviors are rational, I think. Last time I made decision, I > took performance. Set behavoir can be (and is) implemented > efficiently by using hash. OTOH bag behavior was slow. > > There's no reason to make "-" to remove duplication (other than > performance), so that if someone persuade me, it might be change in > the future. In that case, it would be useful to define new operation > for set subtraction, maybe. I didn't intend to say that I do not like it the way it is. In fact, I do. If an array contains duplicate elements, which of them should be removed? The first? The last? A randomly chosen one? (just kidding) A 'user defined' one? That would of course require another parameter. => IMHO, methods like 'removeFirst' (resp. removeLast) would be suited for such an operation. You can of course define them yourself in case you need them. Stephan