instance method
Module#remove_class_variable
(::interned arg0) -> untyped
remove_class_variable(sym) → obj
object.c
View on GitHub ↗
VALUE
rb_mod_remove_cvar(VALUE mod, VALUE name)
{
const ID id = id_for_var_message(mod, name, class, "wrong class variable name %1$s");
st_data_t val;
if (!id) {
goto not_defined;
}
rb_check_frozen(mod);
val = rb_ivar_delete(mod, id, Qundef);
if (!UNDEF_P(val)) {
return (VALUE)val;
}
if (rb_cvar_defined(mod, id)) {
rb_name_err_raise("cannot remove %1$s for %2$s", mod, ID2SYM(id));
}
not_defined:
rb_name_err_raise("class variable %1$s not defined for %2$s",
mod, name);
UNREACHABLE_RETURN(Qundef);
}
Removes the named class variable from the receiver, returning that variable’s value.
Example
class Example @@var = 99 puts remove_class_variable(:@@var) p(defined? @@var) end
produces:
Example
99 nil
See also
#refinements
#remove_const
#refine
#remove_method
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0