January 2020
Intermediate to advanced
532 pages
13h 31m
English
The first solution is to pass the required data as a function argument. Suppose that the payment function from the Mortgage sub-module can take a days_per_year keyword argument, then the Calculator module can just pass the value as follows:
# Calculator.jlmodule Calculatorconst days_per_year = 365include("Mortgage.jl")using .Mortgage: paymentfunction do_something() return payment(1000.00, 3.25, 5; days_per_year = days_per_year)endend # module
Hence, the Mortgage sub-module does not really need to reference the days_per_year symbol from Calculator anymore, reducing any unnecessary dependency.
Read now
Unlock full access