May 2019
Beginner to intermediate
466 pages
10h 44m
English
Like all programming languages that implement OOP features, Julia allows developers to define rich and expressive type hierarchies. However, unlike most OOP languages, there is a very important difference—only the final (upper) type in the hierarchy can be instantiated in Julia. All its parents are just nodes in the type graph, and we can't create instances of them. They are abstract types and are defined using the abstract type keywords:
julia> abstract type Person end
We can use the <: operator to indicate that a type is a subtype of an existing parent:
julia> abstract type Mammal end
julia> abstract type Person <: Mammal end
julia> mutable struct Player <: Person
username::String
score::Int
end
Or, in another ...
Read now
Unlock full access