Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symmetric difference set operation #63

Open
heinezen opened this issue Aug 31, 2019 · 1 comment
Open

Symmetric difference set operation #63

heinezen opened this issue Aug 31, 2019 · 1 comment
Labels
hacktoberfest improvement improves existing functionality nice new thing ☺ adds new functionality specification involves the nyan language specification

Comments

@heinezen
Copy link
Member

Symmetric difference, disjunctive union, XOR - or whatever you call it - is a set operation where the resulting set is composed of elements which are present in either set, but not in both. The corresponding python operator is ^=.

This operation would lower the required patches for "replacement" changes such as the replacement of a move ability.

Without XOR (2 patches):

PatchRemove<SomeUnit>(..):
    abilities -= {OldMove}

PatchAdd<SomeUnit>(..):
    abilities += {NewMove}

With XOR (1 patch):

PatchXOR<SomeUnit>(..)
    # OldMove will be removed because it is in both sets
    abilities ^= {OldMove, NewMove}
@heinezen heinezen added improvement improves existing functionality nice new thing ☺ adds new functionality specification involves the nyan language specification labels Aug 31, 2019
@TheJJ
Copy link
Member

TheJJ commented Aug 31, 2019

We can add it, but I would be careful because if an unforseen mod already adds an ability you want to add know, the ^= will remove it then even though you intended to add it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest improvement improves existing functionality nice new thing ☺ adds new functionality specification involves the nyan language specification
Projects
None yet
Development

No branches or pull requests

2 participants