Singleton: Difference between revisions

added ruby
(→‎Non-Thread-Safe: NSObject are into OpenStep and "derivated" (like GNUstep, Cocoa))
(added ruby)
Line 354:
}
</java>
 
=={{header|Ruby}}==
 
<ruby>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"</ruby>
Anonymous user