remove_const(p1)
private
Removes the definition of the given constant, returning that constant’s
previous value. If that constant referred to a module, this will not
change that module’s name and can lead to
confusion.
Show source
VALUE
rb_mod_remove_const(VALUE mod, VALUE name)
{
const ID id = rb_check_id(&name);
if (!id) {
if (rb_is_const_name(name)) {
rb_name_error_str(name, "constant %"PRIsVALUE"::%"PRIsVALUE" not defined",
rb_class_name(mod), name);
}
else {
rb_name_error_str(name, "`%"PRIsVALUE"' is not allowed as a constant name",
QUOTE(name));
}
}
if (!rb_is_const_id(id)) {
rb_name_error(id, "`%"PRIsVALUE"' is not allowed as a constant name",
QUOTE_ID(id));
}
return rb_const_remove(mod, id);
}