title: How to count instances of class without counting reassignment?
body: <p>I am working on class methods. </p>
  
  <p>I am trying to count the number of created instances of a class. I am able to do this by creating a counter variable in the <code>initialize</code> method.</p>
  
  <p>The problem arises when I reassign the variable originally assigned to one class instance. Because the <code>initialize</code> method is called twice, it does not recognize that the variable is simply being reassigned to another class instance. </p>
  
  <pre><code>class Ticket
      attr_accessor :price
      attr_reader :event, :venue
  
      @@count = 0
      @@tickets = {}
  
      def initialize(event, venue)
          @event = event
          @venue = venue
  
          @@count += 1
      end
  
      def self.count
          @@count 
      end
  end
  
  a = Ticket.new("Michael Buble", "Staples")
  
  a = Ticket.new("Frank Sinatra", "Madison Square Garden")
  
  puts "Ticket count of #{Ticket.count}"
  </code></pre>
  
  <p>When I run the above code in IRB, it gives me a <code>Ticket count of 2</code> (as expected). How do I change my code so that it recognizes the overwrite?</p>
  
  <p>NOTE: I know that this question has been asked before for Objective C, but the reassignment aspect of the question adds a different element to the problem. Let me know otherwise. </p>