all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
9
Task/Singleton/Ruby/singleton.rb
Normal file
9
Task/Singleton/Ruby/singleton.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
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"
|
||||
Loading…
Add table
Add a link
Reference in a new issue