Add intersections and unions to Set

Tab Atkins Jr. jackalmage at
Tue Mar 5 09:33:02 PST 2013

On Tue, Mar 5, 2013 at 8:53 AM, Jason Orendorff
<jason.orendorff at> wrote:
> On Tue, Mar 5, 2013 at 8:15 AM, David Bruant <bruant.d at> wrote:
>> I agree on the need but forsee problems with parametrized equivalence
>> operator [1][2] like "which comparator should be used for the union of 2
>> sets with different comparators?"
> I vote TypeError. If I really do intend to mix two incompatible Sets, I can
> go ahead and write it longhand, which is what, 3 lines? 2 with
> set.addAll(iterable).

Alternately, just use the comparator of the first set (the one you're
calling the method on).  If we add generic (non-method) forms, then
actually take the first one.

I'm loathe to throw a TypeError when it's difficult (impossible?) to
check two sets for equivalent comparators, so you'd have to wrap every
Set mixing operation in a try/catch if you can't be 100% certain that
they use the same comparators.


More information about the es-discuss mailing list