January 2020
Intermediate to advanced
532 pages
13h 31m
English
The second option is a little more interesting. We have switched the type parameter from Float64 to Number, which is the topmost abstract type in the numeric type hierarchy:
sumprod_2(A::Vector{Number}, B::Vector{Number}) = sum(A .* B)
Let's test it now:

At first glance, it may appear that using Number as a type parameter would make it more generic. It turns that out that it can only accept an array of Number types, which means that it has to be a heterogenous array where each element can be a different type as long as all element types are subtypes of Number. For that reason, a vector of Float64
Read now
Unlock full access