Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Single
- private_class_method :new
- @@instance = nil
- def self.getInstance
- @@instance = new if @@instance == nil
- p "getInstance Call"
- end
- def initialize
- p "New instance!"
- end
- end
- obj1 = Single.getInstance
- obj2 = Single.getInstance
- #"New instance!"
- #"getInstance Call"
- #"getInstance Call"
Advertisement
Add Comment
Please, Sign In to add comment