Can someone please explain how self.number_of_instances works? I don't recall learning this.



I'm a beginner having the same question.
Here's what I found on

Self( )
Return the trace object during event
same as #binding:

Binding( )
Return the generated binding object from event

not totaly clear in my head, yet.


self refers to the current class, when inside of it.

We're defining a method called number_of_instances, but which will be called from the class of the object, as demonstrated in the rest of the code:

puts "Number of Person instances: #{Person.number_of_instances}"