Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Set#subtract
(::_Each[A]) -> self
subtract(enumerable) → self
set.c
View on GitHub ↗
static VALUE
set_i_subtract(VALUE set, VALUE other)
{
rb_check_frozen(set);
set_remove_enum_from(set, other);
return set;
}
Deletes from self every element found in the given enumerable; returns self:
Example
set = Set[*0..9] # => Set[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] set.subtract(5..14) # => Set[0, 1, 2, 3, 4] set.subtract(Set[6, 2]) # => Set[0, 1, 3, 4]
Related: see Methods for Deleting.