Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Module#remove_const
(::interned name) -> untyped
remove_const(sym) → obj
object.c
View on GitHub ↗
VALUE
rb_mod_remove_const(VALUE mod, VALUE name)
{
const ID id = id_for_var(mod, name, a, constant);
if (!id) {
undefined_constant(mod, name);
}
return rb_const_remove(mod, id);
}
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.
See also
#remove_class_variable
#remove_method
#refinements
#ruby2_keywords
also in
4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0