Ruby Language Singleton Class Accessing Singleton Class


Example

There are two ways to get singleton class of an object

  • singleton_class method.
  • Reopening singleton class of an object and returning self.
object.singleton_class

singleton_class = class << object
  self
end