Let’s talk about self(and methods), baby.

class Cat
def self.meow #self belongs to the Cat class
self
end
end
Cat.meow == Cat # => true
class Cat 
def meow #this is an instance method
self
end
end
garfield = Cat.new #this is also saying Cat.new.meow
garfield.meow == garfield # => true

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store