On Tue, Oct 16, 2018 at 3:21 PM Ian Denhardt <[email protected]> wrote:
> Quoting Patrick Smith (2018-10-16 18:04:05)
> > One way to avoid this is to supply the adaptor when the Set is
> created,
> > store it in the Set, and thereafter used the stored adaptor instead of
> > requiring an adaptor parameter.
>
> This works for insert/member, but what about union, which takes two
> sets? You could still run into problems if the sets were initialized
> with different adaptors.
>
True. Although:
The union function could verify that the two adaptors are the same, using
the == operator, and panic if not. However, this breaks down if the
adaptors, instead of being defined as struct{}, are defined as types which
don't support ==.
This could even be construed as a feature. The union function takes two
sets, possibly with different adaptors, and merges their contents into a
new set using an adaptor passed as a parameter to union, and which could be
different from the adaptors for both input sets.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.