Module 24 Β· The Ruby Object Model β Lesson 2 of 6 Β· ~11 min
self β the Default Object
self is the answer to "who am I right now?"
At every point in a running Ruby program, exactly one object is self β the default receiver. Any method call with no explicit receiver (save, puts, validates) is sent to self. Knowing what self is at a given line is the single most useful skill for reading unfamiliar Ruby, because it tells you where a bare method call is actually going.
In an interview, say: "
selfis whichever object is currently receiving messages. It changes as you move between the top level, a class body, an instance method, and a class method β and knowing which one you're in tells you where every bare call resolves."