Skip to content

Instantly share code, notes, and snippets.

@apeiros
Last active August 29, 2015 14:23
Show Gist options
  • Save apeiros/b1176723546f7271be60 to your computer and use it in GitHub Desktop.
Save apeiros/b1176723546f7271be60 to your computer and use it in GitHub Desktop.
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