/ Published in: Ruby
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
# 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" end end end # invoke a class method TheClass.hello # hi