RosettaCodeData/Task/Singleton/Ruby/singleton.rb

10 lines
246 B
Ruby
Raw Permalink Normal View History

2013-04-11 01:07:29 -07:00
require 'singleton'
class MySingleton
include Singleton
# constructor and/or methods go here
end
a = MySingleton.instance # instance is only created the first time it is requested
b = MySingleton.instance
puts a.equal?(b) # outputs "true"