Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

Module#singleton_class?

() -> bool
mod.singleton_class? → true or false

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