January 2020
Intermediate to advanced
532 pages
13h 31m
English
Composite types are defined with the struct keyword. Let's carry on the example from the preceding abstract type section and continue building our personal asset type hierarchy. We will now create a concrete type called Stock as a subtype of Equity. To keep things simple, we will just represent a stock as a trading symbol and the name of the company:
struct Stock <: Equity symbol::String name::Stringend
We can instantiate a composite type using the standard constructor, which just takes all the fields as an argument:

Now, since Stock is a subtype of Equity, which is a subtype of Investment, which in turn is a subtype ...
Read now
Unlock full access