Mega Code Archive

 
Categories / Ruby / Class
 

Self represents the current class

# def self.test_method defines the method as being specific to the class.  # with no prefix, methods are automatically instance methods. class Square   def self.test_method     puts "Hello from the Square class!"   end   def test_method     puts "Hello from an instance of class Square!"   end end Square.test_method Square.new.test_method