Singleton Class

suggest change

Syntax

Remarks

Singleton classes only have one instance: their corresponding object. This can be verified by querying Ruby’s ObjectSpace:

instances = ObjectSpace.each_object object.singleton_class

instances.count            # => 1
instances.include? object  # => true

Using \<, they can also be verified to be subclasses of the object’s actual class:

object.singleton_class < object.class  # => true

References:

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents