Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
README.md
ruby-object-inheritance_notes.pdf

README.md

LESSON: ruby-object-inheritance


2018-07-06

OBJECTIVES

By the end of this, developers should be able to:

  • Diagram the Ruby method lookup chain
  • Write a class which inherits from another class.

VOCABULARY

Inheritance: They way objects inherit methods and properties from their parent classes.

Superclass: Classes themselves can inherit from other classes, and these parents classes of classes are called superclasses.

Method Lookup Chain: When a method is called on an object, it will look within it's own instance for methods with that name, and if not found, will go to the parent class and try to find the method, and if not found, go to that class' parent and try to find the method etc until either the method is found, and then run, or it is not found, returning nil / undefined .

Overriding: When a class inherits from a superclass and the superclass has a method that is also named in the child class, the child class is the method that gets called on objects, ie it overrides access to the superclass method and uses it's own method of the same name instead.