January 2020
Intermediate to advanced
532 pages
13h 31m
English
In general, we can replace any abstract type with a type parameter in the function signature. When we do this, we will end up with a parametric method that has the same semantics as the original one.
This is not an unimportant observation. Let's see if we can demonstrate this behavior with an example.
Suppose that we are building a tow function so that a spaceship can tow away something in the universe, as follows:
# specifying abstract/concrete types in method signaturefunction tow(A::Spaceship, B::Thing) "tow 1"end
The tow function is currently defined with a concrete Spaceship type and an abstract Thing type argument. If we want to see the methods defined for this function, we can use the
Read now
Unlock full access