instance method
Set#clear
() -> self
clear → self
set.c
View on GitHub ↗
static VALUE
set_i_clear(VALUE set)
{
rb_check_frozen(set);
if (RSET_SIZE(set) == 0) return set;
if (set_iterating_p(set)) {
set_iter(set, set_clear_i, 0);
}
else {
set_table_clear(RSET_TABLE(set));
set_compact_after_delete(set);
}
return set;
}
Removes all elements and returns self.
Example
set = Set[1, 'c', :s] #=> Set[1, "c", :s] set.clear #=> Set[] set #=> Set[]