Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Singleton In Ruby

DZone's Guide to

Singleton In Ruby

· ·
Free Resource
// simple singleton


class Singleton 
  private_class_method :new
  @@singleton = nil
  
  def Singleton.create
    @@singleton = new unless @@singleton
    @@singleton
  end
end
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}