November 2017
Beginner
316 pages
6h 40m
English
We have seen how we can create a module using the module keyword. However, what if our package, or module, is spread up into different files? The way Julia addresses this issue is by introducing include, which can be used to include any Julia file (with the .jl extension) in a module.
Here is an example that will make things clear. Suppose that we have a module with the PointTypes name, and our code for it is written in the transformations.jl. It contains:
function move(p::Point, x, y) slidex(p, x) slidey(p, y)endfunction slidex(p::Point, dist) p.x += distendfunction slidey(p::Point, dist) p.y += distend
Once we are done with module creation, the next step would be to test the same. This can be done as follows: ...
Read now
Unlock full access