January 2020
Intermediate to advanced
532 pages
13h 31m
English
For the purposes of illustration, we will consider a popular type hierarchy that is used by some of the OOP literature— the animal kingdom! Everyone loves cats and dogs. I have also included crocodiles here to explain related concepts:

The corresponding code to build such a hierarchy is as follows:
abstract type Vertebrate endabstract type Mammal <: Vertebrate endabstract type Reptile <: Vertebrate endstruct Cat <: Mammal nameendstruct Dog <: Mammal nameendstruct Crocodile <: Reptile nameend
For convenience, we can also define the show function for these new types:
Base.show(io::IO, cat::Cat) = print(io, "Cat ...
Read now
Unlock full access