/ Published in: Ruby
- # How to define and use a singleton class
- # - modifies the class's class
- # - instance methods in the singleton class are class methods externally
- class TheClass
- class << self
- def hello
- puts "hi"
- # invoke a class method
- TheClass.hello # hi
You need to login to post a comment.