End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Module#singleton_class?
mod.singleton_class? → true or false
object.c
View on GitHub ↗
static VALUE
rb_mod_singleton_p(VALUE klass)
{
return RBOOL(RB_TYPE_P(klass, T_CLASS) && FL_TEST(klass, FL_SINGLETON));
}
Returns true if mod is a singleton class or false if it is an ordinary class or module.
Example
class C end C.singleton_class? #=> false C.singleton_class.singleton_class? #=> true
See also
#ruby2_keywords
#to_s
#remove_method
#undef_method
also in
4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0