January 2020
Intermediate to advanced
532 pages
13h 31m
English
The next step is to assign data types to these traits. Conveniently, Julia allows us to bulk-assign traits to an entire subtype tree using the <: operator in the function signature:
# Default behavior is illiquidLiquidityStyle(::Type) = IsIlliquid()# Cash is always liquidLiquidityStyle(::Type{<:Cash}) = IsLiquid()# Any subtype of Investment is liquidLiquidityStyle(::Type{<:Investment}) = IsLiquid()
Let's take a look at how we can interpret these three lines of code:
Read now
Unlock full access