From: matz@... (Yukihiro Matsumoto) Date: 2000-12-03T23:33:44+09:00 Subject: [ruby-talk:6765] Re: Array Intersect (&) question Hi, In message "[ruby-talk:6755] Re: Array Intersect (&) question" on 00/12/03, "Brian F. Feldman" writes: |Personally, I feel that a non-ordered &() method would violate the POLS for |a lot of people, including myself. How about adding a faster version as |intersection(), then? I'm sure a similar situation exists with |() and can |be optimized by making a new union(). I think I'm going to re-implement & and | using hash, preserving current result order. |I like highly deterministic API calls - preserving order and object |duplication would be the only reasonable default, in my humble opinion. But what do you mean by `preserving object duplication'? Do you agree with Ross's opinion? [ruby-talk:6752] > a2 = %w# 1 1 y # -> ["1", "1", "y"] > a3 = %w# 1 y 1 z # -> ["1", "y", "1", "z"] > a2 & a3 -> ["1", "y"] > > Whereas I believe the true intersection of a2 & a3 should be > ["1", "1", "y"] . Opinions? FYI, Current behavior does not preserve duplication. matz.