instance method
Set#^
(::_Each[A]) -> self
set ^ enum → new_set
set.c
View on GitHub ↗
static VALUE
set_i_xor(VALUE set, VALUE other)
{
VALUE new_set = rb_obj_dup(set);
if (rb_obj_is_kind_of(other, rb_cSet)) {
set_iter(other, set_xor_i, (st_data_t)new_set);
}
else {
VALUE tmp = set_s_alloc(rb_cSet);
set_merge_enum_into(tmp, other);
set_iter(tmp, set_xor_i, (st_data_t)new_set);
}
return new_set;
}
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"]