Ruby self

  1. Used in a method for referencing the current object
  def example()
      puts self.instance_var
  end
  1. Use to denote a class method
  class Country
      @@count

      def initialize()
        @@count += 1
      end
      
      def self.population()
        puts @@count
      end
  end

  c = Country.new()
  c.name = 'Test'
  Country.population() # Returns 1