Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Set#^
(::_Each[A]) -> self
^(enum)
lib/set.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.4.1/lib/set.rb, line 664
def ^(enum)
n = self.class.new(enum)
each { |o| n.add(o) unless n.delete?(o) }
n
end
Returns a new set containing elements exclusive between the set and the given enumerable object. (set ^ enum) is equivalent to ((set | enum) - (set & enum)).
Example
Set[1, 2] ^ Set[2, 3] #=> #<Set: {3, 1}> Set[1, 'b', 'c'] ^ ['b', 'd'] #=> #<Set: {"d", 1, "c"}>