January 2020
Intermediate to advanced
532 pages
13h 31m
English
A module can access its sub-modules using the regular using or import statements. In fact, a sub-module does not work any differently than an external package, except how it is being referenced.
Perhaps we can recall the example from Chapter 2, Modules, Packages, and Type Concepts. Back then, we created a Calculator module that defines two interest rate-related functions and a Mortgage sub-module that defines a payment calculator function. The Calculator module file has the following source code:
# Calculator.jlmodule Calculatorinclude("Mortgage.jl")export interest, ratefunction interest(amount, rate) return amount * (1 + rate)endfunction rate(amount, interest) return interest ...Read now
Unlock full access