-
-
Save apeiros/b1176723546f7271be60 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Enumerable | |
# requires `other` to respond to .each | |
def ^(other) | |
result = {} | |
seen = {} | |
each do |v| | |
result[v] = true | |
end | |
other.each do |v| | |
next if seen.key?(v) | |
seen[v] = true | |
if result.key?(v) | |
result.delete(v) | |
else | |
result[v] = true | |
end | |
end | |
result.keys | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment