Ruby Keyword: self - rking/pry-docmore GitHub Wiki

An ever-present variable in Ruby. At the very top level, it is the "(main)" self, but everywhere else its value is very important to know.

Within a method, it is the instance that received the method.

Within a class defintion, it is the class itself. This explains why:

class Foo
  def self.hi; 'hi' end # this is equivalent to:
  def Foo.hi; 'hi' end # this.
end

TODO:

Explain eigenclasses

…?

⚠️ **GitHub.com Fallback** ⚠️